@@ -18,6 +18,7 @@ pub use libp2p::identity::{Keypair, PublicKey};
18
18
use enr:: { ATTESTATION_BITFIELD_ENR_KEY , ETH2_ENR_KEY , SYNC_COMMITTEE_BITFIELD_ENR_KEY } ;
19
19
use futures:: prelude:: * ;
20
20
use futures:: stream:: FuturesUnordered ;
21
+ use libp2p:: connection_limits:: Exceeded ;
21
22
use libp2p:: multiaddr:: Protocol ;
22
23
use libp2p:: swarm:: behaviour:: { DialFailure , FromSwarm } ;
23
24
use libp2p:: swarm:: THandlerInEvent ;
@@ -1156,8 +1157,19 @@ impl<E: EthSpec> Discovery<E> {
1156
1157
fn on_dial_failure ( & mut self , peer_id : Option < PeerId > , error : & DialError ) {
1157
1158
if let Some ( peer_id) = peer_id {
1158
1159
match error {
1160
+ DialError :: Denied { cause } => {
1161
+ if self . network_globals . peers . read ( ) . is_connected ( & peer_id) {
1162
+ // There's an active connection, so we don’t disconnect the peer.
1163
+ // Lighthouse dials to a peer twice using TCP and QUIC (if QUIC is not
1164
+ // disabled). Usually, one establishes a connection, and the other fails
1165
+ // because the peer allows only one connection per peer.
1166
+ return ;
1167
+ }
1168
+ // set peer as disconnected in discovery DHT
1169
+ debug ! ( self . log, "Marking peer disconnected in DHT" ; "peer_id" => %peer_id, "error" => %ClearDialError ( error) ) ;
1170
+ self . disconnect_peer ( & peer_id) ;
1171
+ }
1159
1172
DialError :: LocalPeerId { .. }
1160
- | DialError :: Denied { .. }
1161
1173
| DialError :: NoAddresses
1162
1174
| DialError :: Transport ( _)
1163
1175
| DialError :: WrongPeerId { .. } => {
0 commit comments