Skip to content

Commit

Permalink
chore: warn if our peer tracking goes out of sync
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin authored and joshuef committed Jun 18, 2024
1 parent 6f346b3 commit f083fb7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sn_networking/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,16 @@ impl SwarmDriver {
.set(estimated_network_size as i64);
}

// Just to warn if our tracking goes out of sync with libp2p. Can happen if someone forgets to call
// update_on_peer_addition or update_on_peer_removal when adding or removing a peer.
// Only log every 10th peer to avoid spamming the logs.
if total_peers % 10 == 0 && total_peers != self.peers_in_rt {
warn!(
"Total peers in routing table: {}, but kbucket table has {total_peers} peers",
self.peers_in_rt
);
}

info!("kBucketTable has {index:?} kbuckets {total_peers:?} peers, {kbucket_table_stats:?}, estimated network size: {estimated_network_size:?}");
}

Expand Down

0 comments on commit f083fb7

Please sign in to comment.