aboutsummaryrefslogtreecommitdiff
path: root/src/peering
diff options
context:
space:
mode:
Diffstat (limited to 'src/peering')
-rw-r--r--src/peering/fullmesh.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs
index 5f17718..22657dd 100644
--- a/src/peering/fullmesh.rs
+++ b/src/peering/fullmesh.rs
@@ -163,7 +163,11 @@ impl FullMeshPeeringStrategy {
/// The strategy will not be run until `.run()` is called and awaited.
/// Once that happens, the peering strategy will try to connect
/// to all of the nodes specified in the bootstrap list.
- pub fn new(netapp: Arc<NetApp>, bootstrap_list: Vec<(NodeID, SocketAddr)>) -> Arc<Self> {
+ pub fn new(
+ netapp: Arc<NetApp>,
+ bootstrap_list: Vec<(NodeID, SocketAddr)>,
+ our_addr: Option<SocketAddr>,
+ ) -> Arc<Self> {
let mut known_hosts = KnownHosts::new();
for (id, addr) in bootstrap_list {
if id != netapp.id {
@@ -179,6 +183,18 @@ impl FullMeshPeeringStrategy {
}
}
+ if let Some(addr) = our_addr {
+ known_hosts.list.insert(
+ netapp.id,
+ PeerInfoInternal {
+ addr,
+ state: PeerConnState::Ourself,
+ last_seen: None,
+ ping: VecDeque::new(),
+ },
+ );
+ }
+
let strat = Arc::new(Self {
netapp: netapp.clone(),
known_hosts: RwLock::new(known_hosts),
@@ -188,6 +204,8 @@ impl FullMeshPeeringStrategy {
peer_list_endpoint: netapp.endpoint("__netapp/peering/fullmesh.rs/PeerList".into()),
});
+ strat.update_public_peer_list(&strat.known_hosts.read().unwrap());
+
strat.ping_endpoint.set_handler(strat.clone());
strat.peer_list_endpoint.set_handler(strat.clone());