Skip to content

Commit

Permalink
Merge pull request maidsafe#2239 from joshuef/DisconnectBad
Browse files Browse the repository at this point in the history
feat(networking): ensure we disconnect when removing peers
  • Loading branch information
b-zee authored Oct 16, 2024
2 parents 1d14196 + fb17d79 commit 1baca06
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sn_networking/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,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
Expand Down

0 comments on commit 1baca06

Please sign in to comment.