hashiverse_lib/transport/bootstrap_provider/
manual_bootstrap_provider.rs1use crate::transport::bootstrap_provider::bootstrap_provider::BootstrapProvider;
11use std::sync::Arc;
12
13pub struct ManualBootstrapProvider {
14 addresses: Vec<String>,
15}
16
17impl ManualBootstrapProvider {
18 #[allow(clippy::should_implement_trait)] pub fn default() -> Arc<Self> {
20 Self::new(vec![])
21 }
22 pub fn new(addresses: Vec<String>) -> Arc<Self> {
23 Arc::new(Self { addresses })
24 }
25 pub fn new_tcp_localhost() -> Arc<Self> {
26 Arc::new(Self { addresses: vec!["127.0.0.1:443".to_string()] })
27 }
28 pub fn new_mem_multiple() -> Arc<Self> {
29 Arc::new(Self {
30 addresses: vec![
31 "443".to_string(),
32 "10000".to_string(),
33 "20000".to_string(),
34 "20001".to_string(),
35 "20002".to_string(),
36 "20003".to_string(),
37 "20004".to_string(),
38 "20005".to_string(),
39 "20006".to_string(),
40 "20007".to_string(),
41 "20008".to_string(),
42 "20009".to_string(),
43 "20010".to_string(),
44 "20011".to_string(),
45 "20012".to_string(),
46 "20013".to_string(),
47 "20014".to_string(),
48 "20015".to_string(),
49 "20016".to_string(),
50 "20017".to_string(),
51 "20018".to_string(),
52 "20019".to_string(),
53 ],
54 })
55 }
56}
57
58#[async_trait::async_trait]
59impl BootstrapProvider for ManualBootstrapProvider {
60 async fn get_bootstrap_addresses(&self) -> Vec<String> {
61 self.addresses.clone()
62 }
63}