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:
parent
52c69c4eee
commit
eee0260a68
@ -350,8 +350,13 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
|
|||||||
|
|
||||||
/// Reports whether the peer limit is reached in which case we stop allowing new incoming
|
/// Reports whether the peer limit is reached in which case we stop allowing new incoming
|
||||||
/// connections.
|
/// connections.
|
||||||
pub fn peer_limit_reached(&self) -> bool {
|
pub fn peer_limit_reached(&self, count_dialing: bool) -> bool {
|
||||||
self.network_globals.connected_or_dialing_peers() >= self.max_peers()
|
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.
|
/// Updates `PeerInfo` with `identify` information.
|
||||||
|
@ -112,15 +112,7 @@ impl<TSpec: EthSpec> NetworkBehaviour for PeerManager<TSpec> {
|
|||||||
_failed_addresses: Option<&Vec<Multiaddr>>,
|
_failed_addresses: Option<&Vec<Multiaddr>>,
|
||||||
) {
|
) {
|
||||||
// Log the connection
|
// Log the connection
|
||||||
match &endpoint {
|
debug!(self.log, "Connection established"; "peer_id" => %peer_id, "connection" => ?endpoint.to_endpoint());
|
||||||
ConnectedPoint::Listener { .. } => {
|
|
||||||
debug!(self.log, "Connection established"; "peer_id" => %peer_id, "connection" => "Incoming");
|
|
||||||
}
|
|
||||||
ConnectedPoint::Dialer { .. } => {
|
|
||||||
debug!(self.log, "Connection established"; "peer_id" => %peer_id, "connection" => "Outgoing");
|
|
||||||
// TODO: Ensure we have that address registered.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check to make sure the peer is not supposed to be banned
|
// Check to make sure the peer is not supposed to be banned
|
||||||
match self.ban_status(peer_id) {
|
match self.ban_status(peer_id) {
|
||||||
@ -142,8 +134,10 @@ impl<TSpec: EthSpec> NetworkBehaviour for PeerManager<TSpec> {
|
|||||||
BanResult::NotBanned => {}
|
BanResult::NotBanned => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count dialing peers in the limit if the peer dialied us.
|
||||||
|
let count_dialing = endpoint.is_listener();
|
||||||
// Check the connection limits
|
// Check the connection limits
|
||||||
if self.peer_limit_reached()
|
if self.peer_limit_reached(count_dialing)
|
||||||
&& self
|
&& self
|
||||||
.network_globals
|
.network_globals
|
||||||
.peers
|
.peers
|
||||||
|
Loading…
Reference in New Issue
Block a user