Skip to content

Commit

Permalink
Filter private addresses early to do less work overall
Browse files Browse the repository at this point in the history
nazar-pc committed Nov 18, 2023
1 parent 185767c commit 1e478b2
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions crates/subspace-networking/src/node_runner.rs
Original file line number Diff line number Diff line change
@@ -733,8 +733,27 @@ where
});

if full_kademlia_support {
let received_address_strings = info
let received_addresses = info
.listen_addrs
.into_iter()
.filter(|address| {
if self.allow_non_global_addresses_in_dht
|| is_global_address_or_dns(address)
{
true
} else {
trace!(
%local_peer_id,
%peer_id,
%address,
"Ignoring self-reported non-global address",
);

false
}
})
.collect::<Vec<_>>();
let received_address_strings = received_addresses
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>();
@@ -762,19 +781,7 @@ where
})
.unwrap_or_default();

for address in info.listen_addrs {
if !self.allow_non_global_addresses_in_dht
&& !is_global_address_or_dns(&address)
{
trace!(
%local_peer_id,
%peer_id,
%address,
"Ignoring self-reported non-global address",
);
continue;
}

for address in received_addresses {
debug!(
%local_peer_id,
%peer_id,

0 comments on commit 1e478b2

Please sign in to comment.