File tree Expand file tree Collapse file tree 2 files changed +17
-16
lines changed
beacon_node/eth2_libp2p/src/peer_manager Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -668,16 +668,18 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
668
668
. cached_enrs ( )
669
669
. filter_map ( |( peer_id, enr) | {
670
670
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
+ {
672
675
Some ( * peer_id)
673
676
} else {
674
677
None
675
678
}
676
679
} )
677
680
. 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) ;
681
683
}
682
684
}
683
685
@@ -696,7 +698,16 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
696
698
// we attempt a connection if this peer is a subnet peer or if the max peer count
697
699
// is not yet filled (including dialing peers)
698
700
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)
700
711
{
701
712
// This should be updated with the peer dialing. In fact created once the peer is
702
713
// dialed
Original file line number Diff line number Diff line change @@ -153,16 +153,6 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
153
153
)
154
154
}
155
155
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
-
166
156
/// Returns true if the peer is synced at least to our current head.
167
157
pub fn is_synced ( & self , peer_id : & PeerId ) -> bool {
168
158
match self . peers . get ( peer_id) . map ( |info| & info. sync_status ) {
@@ -351,7 +341,7 @@ impl<TSpec: EthSpec> PeerDB<TSpec> {
351
341
}
352
342
353
343
if let Err ( e) = info. dialing_peer ( ) {
354
- error ! ( self . log, "{}" , e; "peer_id" => %peer_id ) ;
344
+ error ! ( self . log, "{}" , e) ;
355
345
}
356
346
}
357
347
You can’t perform that action at this time.
0 commit comments