Skip to content

Commit 44b1d15

Browse files
committed
Revert "More stringent dialing (sigp#2363)"
This reverts commit 55aada0.
1 parent d12e746 commit 44b1d15

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

beacon_node/eth2_libp2p/src/peer_manager/mod.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,16 +668,18 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
668668
.cached_enrs()
669669
.filter_map(|(peer_id, enr)| {
670670
let peers = self.network_globals.peers.read();
671-
if predicate(enr) && peers.should_dial(peer_id) {
671+
if predicate(enr)
672+
&& !peers.is_connected_or_dialing(peer_id)
673+
&& !peers.is_banned(peer_id)
674+
{
672675
Some(*peer_id)
673676
} else {
674677
None
675678
}
676679
})
677680
.collect();
678-
for peer_id in &peers_to_dial {
679-
debug!(self.log, "Dialing cached ENR peer"; "peer_id" => %peer_id);
680-
self.dial_peer(peer_id);
681+
for peer in &peers_to_dial {
682+
self.dial_peer(peer);
681683
}
682684
}
683685

@@ -696,7 +698,16 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
696698
// we attempt a connection if this peer is a subnet peer or if the max peer count
697699
// is not yet filled (including dialing peers)
698700
if (min_ttl.is_some() || connected_or_dialing + to_dial_peers.len() < self.max_peers)
699-
&& self.network_globals.peers.read().should_dial(&peer_id)
701+
&& !self
702+
.network_globals
703+
.peers
704+
.read()
705+
.is_connected_or_dialing(&peer_id)
706+
&& !self
707+
.network_globals
708+
.peers
709+
.read()
710+
.is_banned_or_disconnected(&peer_id)
700711
{
701712
// This should be updated with the peer dialing. In fact created once the peer is
702713
// dialed

beacon_node/eth2_libp2p/src/peer_manager/peerdb.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,6 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
153153
)
154154
}
155155

156-
/// Returns true if the peer should be dialed. This checks the connection state and the
157-
/// score state and determines if the peer manager should dial this peer.
158-
pub fn should_dial(&self, peer_id: &PeerId) -> bool {
159-
matches!(
160-
self.connection_status(peer_id),
161-
Some(PeerConnectionStatus::Disconnected { .. })
162-
| Some(PeerConnectionStatus::Unknown { .. })
163-
) && !self.is_banned_or_disconnected(peer_id)
164-
}
165-
166156
/// Returns true if the peer is synced at least to our current head.
167157
pub fn is_synced(&self, peer_id: &PeerId) -> bool {
168158
match self.peers.get(peer_id).map(|info| &info.sync_status) {
@@ -351,7 +341,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
351341
}
352342

353343
if let Err(e) = info.dialing_peer() {
354-
error!(self.log, "{}", e; "peer_id" => %peer_id);
344+
error!(self.log, "{}", e);
355345
}
356346
}
357347

0 commit comments

Comments
 (0)