Skip to content

Commit

Permalink
Small logging tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Nov 12, 2023
1 parent 65401a4 commit 8dcfee8
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions crates/subspace-networking/src/node_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ where
%local_peer_id,
%peer_id,
%address,
"Ignoring self-reported non-global address.",
"Ignoring self-reported non-global address",
);
continue;
}
Expand All @@ -741,24 +741,18 @@ where
%local_peer_id,
%peer_id,
%address,
"Adding self-reported address to Kademlia DHT ({:?}).",
kademlia
.protocol_names()
.iter()
.collect::<Vec<_>>(),
protocol_names = ?kademlia.protocol_names(),
"Adding self-reported address to Kademlia DHT",
);
kademlia.add_address(&peer_id, address);
}
} else {
debug!(
%local_peer_id,
%peer_id,
peer_protocols=?info.protocols,
"Peer doesn't support our Kademlia DHT protocol ({:?}).",
kademlia
.protocol_names()
.iter()
.collect::<Vec<_>>(),
peer_protocols = ?info.protocols,
protocol_names = ?kademlia.protocol_names(),
"Peer doesn't support our Kademlia DHT protocol",
);

kademlia.remove_peer(&peer_id);
Expand All @@ -773,22 +767,24 @@ where
fn add_observed_external_address(&mut self, observed_addr: Multiaddr) {
if !self.external_addresses.is_empty() {
debug!(
"Observed address wasn't added as external (manual external addresses set): {}",
observed_addr
%observed_addr,
"Ignoring observed address, configured explicitly during startup",
);
return;
}

let Some(listen_addr) = self.swarm.listeners().next() else {
warn!("Listener addresses are not specified!");
debug!(
"Listener addresses are not specified, will not accept observed external address"
);
return;
};

let Some(observed_addr) = address_translation(listen_addr, &observed_addr) else {
warn!(
?listen_addr,
?observed_addr,
"Can't translate observed address!"
%listen_addr,
%observed_addr,
"Can't translate observed address"
);
return;
};
Expand All @@ -800,10 +796,10 @@ where
.collect::<Vec<_>>()
.contains(&observed_addr)
{
info!("Added observed address as external: {}", observed_addr);
info!(%observed_addr, "Added observed address as external");
self.swarm.add_external_address(observed_addr);
} else {
trace!("Skipping known external address: {}", observed_addr);
trace!(%observed_addr, "Skipping known external address");
}
}

Expand All @@ -817,7 +813,7 @@ where
debug!("Unexpected AddProvider request received: {:?}", record);
}
KademliaEvent::UnroutablePeer { peer } => {
debug!("Unroutable peer detected: {:?}", peer);
debug!(%peer, "Unroutable peer detected");

self.swarm.behaviour_mut().kademlia.remove_peer(&peer);

Expand Down

0 comments on commit 8dcfee8

Please sign in to comment.