From 27a4b83b7048ccef05b0f42275f213e4b99c191b Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Tue, 15 Oct 2024 15:52:10 +0900 Subject: [PATCH] feat(networking): ensure we disconnect when removing peers --- sn_networking/src/event/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sn_networking/src/event/mod.rs b/sn_networking/src/event/mod.rs index ad6e1781b6..fc87e285a2 100644 --- a/sn_networking/src/event/mod.rs +++ b/sn_networking/src/event/mod.rs @@ -268,6 +268,11 @@ impl SwarmDriver { /// Update state on removal of a peer from the routing table. pub(crate) fn update_on_peer_removal(&mut self, removed_peer: PeerId) { self.peers_in_rt = self.peers_in_rt.saturating_sub(1); + + // ensure we disconnect bad peer + // err result just means no connections were open + let _result = self.swarm.disconnect_peer_id(removed_peer); + info!( "Peer removed from routing table: {removed_peer:?}, now we have #{} connected peers", self.peers_in_rt