Skip to content

Commit

Permalink
libp2p: Revert discovery address check from stable code
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv committed Nov 18, 2024
1 parent a4720dd commit 2e00419
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions substrate/client/network/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,28 +749,16 @@ impl NetworkBehaviour for DiscoveryBehaviour {
self.mdns.on_swarm_event(FromSwarm::NewListenAddr(e));
},
FromSwarm::ExternalAddrConfirmed(e @ ExternalAddrConfirmed { addr }) => {
let mut address = addr.clone();
let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id));

if let Some(Protocol::P2p(peer_id)) = addr.iter().last() {
if peer_id != self.local_peer_id {
warn!(
target: "sub-libp2p",
"🔍 Discovered external address for a peer that is not us: {addr}",
);
// Ensure this address is not propagated to kademlia.
return
}
} else {
address.push(Protocol::P2p(self.local_peer_id));
}

if Self::can_add_to_dht(&address) {
if Self::can_add_to_dht(addr) {
// NOTE: we might re-discover the same address multiple times
// in which case we just want to refrain from logging.
if self.known_external_addresses.insert(address.clone()) {
if self.known_external_addresses.insert(new_addr.clone()) {
info!(
target: "sub-libp2p",
"🔍 Discovered new external address for our node: {address}",
"🔍 Discovered new external address for our node: {}",
new_addr,
);
}
}
Expand Down

0 comments on commit 2e00419

Please sign in to comment.