@@ -149,7 +149,7 @@ pub struct Config {
149
149
/// How many entries of discovered peers to keep before we discard
150
150
/// the least-recently used one.
151
151
///
152
- /// Disabled by default.
152
+ /// Defaults to 100
153
153
cache_size : usize ,
154
154
155
155
/// Whether to include our listen addresses in our responses. If enabled,
@@ -591,13 +591,24 @@ impl NetworkBehaviour for Behaviour {
591
591
self . outbound_connections_with_ephemeral_port
592
592
. remove ( & connection_id) ;
593
593
}
594
- FromSwarm :: DialFailure ( DialFailure { peer_id, error, .. } ) => {
595
- if let ( Some ( peer_id) , Some ( cache) , DialError :: Transport ( errors) ) =
596
- ( peer_id, self . discovered_peers . 0 . as_mut ( ) , error)
597
- {
598
- for ( addr, _error) in errors {
599
- cache. remove ( & peer_id, addr) ;
600
- }
594
+ FromSwarm :: DialFailure ( DialFailure {
595
+ peer_id : Some ( peer_id) ,
596
+ error,
597
+ ..
598
+ } ) => {
599
+ if let Some ( cache) = self . discovered_peers . 0 . as_mut ( ) {
600
+ match error {
601
+ DialError :: Transport ( errors) => {
602
+ for ( addr, _error) in errors {
603
+ cache. remove ( & peer_id, addr) ;
604
+ }
605
+ }
606
+ DialError :: WrongPeerId { address, .. }
607
+ | DialError :: LocalPeerId { address } => {
608
+ cache. remove ( & peer_id, address) ;
609
+ }
610
+ _ => ( ) ,
611
+ } ;
601
612
}
602
613
}
603
614
_ => { }
0 commit comments