do not count dialing peers in the connection limit (#2856)

## Issue Addressed
#2841 

## Proposed Changes
Not counting dialing peers while deciding if we have reached the target peers in case of outbound peers.

## Additional Info
Checked this running in nodes and bandwidth looks normal, peer count looks normal too
This commit is contained in:
Divma
2021-12-15 05:48:45 +00:00
parent 52c69c4eee
commit eee0260a68
2 changed files with 11 additions and 12 deletions

View File

@@ -350,8 +350,13 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
/// Reports whether the peer limit is reached in which case we stop allowing new incoming
/// connections.
pub fn peer_limit_reached(&self) -> bool {
self.network_globals.connected_or_dialing_peers() >= self.max_peers()
pub fn peer_limit_reached(&self, count_dialing: bool) -> bool {
let max_peers = self.max_peers();
if count_dialing {
self.network_globals.connected_or_dialing_peers() >= max_peers
} else {
self.network_globals.connected_peers() >= max_peers
}
}
/// Updates `PeerInfo` with `identify` information.