mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
Remove duplicated connection limits checks (#6156)
* move main Behaviour to mod.rs for better readibility and remove connection limits checks after connection has been established, as those checks have already been done by connection limits Behaviour. * improve logging wording wrt dial logic when we call dial_peer we are not yet dialing but just adding the peer to the dial queue * do not use a constant for MAX_CONNECTIONS_PER_PEER we only use it at one place, and the function call is explicit. * address review and re-instate connection limits checks, but do it before the connection has been established. * Merge branch 'unstable' of github.com:sigp/lighthouse into remove-dial-error-denied * Merge branch 'unstable' of github.com:sigp/lighthouse into remove-dial-error-denied
This commit is contained in:
@@ -338,15 +338,15 @@ impl<E: EthSpec> PeerManager<E> {
|
||||
{
|
||||
// This should be updated with the peer dialing. In fact created once the peer is
|
||||
// dialed
|
||||
let peer_id = enr.peer_id();
|
||||
if let Some(min_ttl) = min_ttl {
|
||||
self.network_globals
|
||||
.peers
|
||||
.write()
|
||||
.update_min_ttl(&enr.peer_id(), min_ttl);
|
||||
.update_min_ttl(&peer_id, min_ttl);
|
||||
}
|
||||
let peer_id = enr.peer_id();
|
||||
if self.dial_peer(enr) {
|
||||
debug!(self.log, "Dialing discovered peer"; "peer_id" => %peer_id);
|
||||
debug!(self.log, "Added discovered ENR peer to dial queue"; "peer_id" => %peer_id);
|
||||
to_dial_peers += 1;
|
||||
}
|
||||
}
|
||||
@@ -447,18 +447,6 @@ impl<E: EthSpec> PeerManager<E> {
|
||||
self.network_globals.peers.read().is_connected(peer_id)
|
||||
}
|
||||
|
||||
/// Reports whether the peer limit is reached in which case we stop allowing new incoming
|
||||
/// connections.
|
||||
pub fn peer_limit_reached(&self, count_dialing: bool) -> bool {
|
||||
if count_dialing {
|
||||
// This is an incoming connection so limit by the standard max peers
|
||||
self.network_globals.connected_or_dialing_peers() >= self.max_peers()
|
||||
} else {
|
||||
// We dialed this peer, allow up to max_outbound_dialing_peers
|
||||
self.network_globals.connected_peers() >= self.max_outbound_dialing_peers()
|
||||
}
|
||||
}
|
||||
|
||||
/// Updates `PeerInfo` with `identify` information.
|
||||
pub fn identify(&mut self, peer_id: &PeerId, info: &IdentifyInfo) {
|
||||
if let Some(peer_info) = self.network_globals.peers.write().peer_info_mut(peer_id) {
|
||||
|
||||
Reference in New Issue
Block a user