From d15378a2245b30fa2094c95bd942c94361f06c4c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 21 Oct 2021 12:24:42 +0200 Subject: [PATCH] invoke handler that wasn't invoked --- src/peering/fullmesh.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/peering/fullmesh.rs b/src/peering/fullmesh.rs index 5b73f4e..068055e 100644 --- a/src/peering/fullmesh.rs +++ b/src/peering/fullmesh.rs @@ -212,13 +212,13 @@ impl FullMeshPeeringStrategy { let strat2 = strat.clone(); netapp.on_connected(move |id: NodeID, addr: SocketAddr, is_incoming: bool| { let strat2 = strat2.clone(); - tokio::spawn(strat2.on_connected(id, addr, is_incoming)); + strat2.on_connected(id, addr, is_incoming); }); let strat2 = strat.clone(); netapp.on_disconnected(move |id: NodeID, is_incoming: bool| { let strat2 = strat2.clone(); - tokio::spawn(strat2.on_disconnected(id, is_incoming)); + strat2.on_disconnected(id, is_incoming); }); strat @@ -424,10 +424,12 @@ impl FullMeshPeeringStrategy { }; self.update_public_peer_list(&known_hosts); } + } else { + self.on_connected(id, addr, false); } } - async fn on_connected(self: Arc, id: NodeID, addr: SocketAddr, is_incoming: bool) { + fn on_connected(self: Arc, id: NodeID, addr: SocketAddr, is_incoming: bool) { if is_incoming { let mut known_hosts = self.known_hosts.write().unwrap(); if !known_hosts.list.contains_key(&id) { @@ -449,7 +451,7 @@ impl FullMeshPeeringStrategy { } } - async fn on_disconnected(self: Arc, id: NodeID, is_incoming: bool) { + fn on_disconnected(self: Arc, id: NodeID, is_incoming: bool) { if !is_incoming { info!("Connection to {} was closed", hex::encode(id)); let mut known_hosts = self.known_hosts.write().unwrap();