Skip to content

Commit 460f1d9

Browse files
authored
Merge branch 'master' into chore/link-workspace-version-edition
2 parents c0d539a + 9228dc2 commit 460f1d9

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

protocols/identify/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Implement optional `signedPeerRecord` support for identify messages.
44
See [PR 5785](https://github.com/libp2p/rust-libp2p/pull/5785)
5+
- Fix `Identify::discovered_peers` to remove peers on `DialError::{WrongPeerId, LocalPeerId}` events.
6+
See [PR 5890](https://github.com/libp2p/rust-libp2p/pull/5890).
57

68
## 0.46.0
79

protocols/identify/src/behaviour.rs

+19-8
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub struct Config {
149149
/// How many entries of discovered peers to keep before we discard
150150
/// the least-recently used one.
151151
///
152-
/// Disabled by default.
152+
/// Defaults to 100
153153
cache_size: usize,
154154

155155
/// Whether to include our listen addresses in our responses. If enabled,
@@ -591,13 +591,24 @@ impl NetworkBehaviour for Behaviour {
591591
self.outbound_connections_with_ephemeral_port
592592
.remove(&connection_id);
593593
}
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+
};
601612
}
602613
}
603614
_ => {}

0 commit comments

Comments
 (0)