Skip to content

Commit

Permalink
chore(network): reduce outdated connection prunning frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Oct 28, 2024
1 parent 81cfbc6 commit 6171017
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sn_networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,12 @@ impl SwarmDriver {
// Remove outdated connection to a peer if it is not in the RT.
// Optionally force remove all the connections for a provided peer.
fn remove_outdated_connections(&mut self) {
// To avoid this being called too frequenctly, only carry out prunning intervally.
if Instant::now() > self.last_connection_pruning_time + Duration::from_secs(30) {
return;
}
self.last_connection_pruning_time = Instant::now();

let mut removed_conns = 0;
self.live_connected_peers.retain(|connection_id, (peer_id, timeout_time)| {

Expand Down

0 comments on commit 6171017

Please sign in to comment.