Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kad): reduce noise of "remote supports our protocol" log #4278

Merged
merged 10 commits into from
Aug 7, 2023
2 changes: 2 additions & 0 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2081,6 +2081,7 @@ where
connected_point,
peer,
self.mode,
connection_id,
))
}

Expand All @@ -2103,6 +2104,7 @@ where
connected_point,
peer,
self.mode,
connection_id,
))
}

Expand Down
21 changes: 14 additions & 7 deletions protocols/kad/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use libp2p_swarm::handler::{
ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound,
};
use libp2p_swarm::{
ConnectionHandler, ConnectionHandlerEvent, KeepAlive, Stream, StreamUpgradeError,
ConnectionHandler, ConnectionHandlerEvent, ConnectionId, KeepAlive, Stream, StreamUpgradeError,
SubstreamProtocol, SupportedProtocols,
};
use log::trace;
Expand Down Expand Up @@ -94,6 +94,9 @@ pub struct KademliaHandler {
protocol_status: ProtocolStatus,

remote_supported_protocols: SupportedProtocols,

/// The current connection ID from the behaviour.
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
connection_id: ConnectionId,
}

/// The states of protocol confirmation that a connection
Expand Down Expand Up @@ -474,6 +477,7 @@ impl KademliaHandler {
endpoint: ConnectedPoint,
remote_peer_id: PeerId,
mode: Mode,
connection_id: ConnectionId,
) -> Self {
match &endpoint {
ConnectedPoint::Dialer { .. } => {
Expand Down Expand Up @@ -504,6 +508,7 @@ impl KademliaHandler {
keep_alive,
protocol_status: ProtocolStatus::Unknown,
remote_supported_protocols: Default::default(),
connection_id,
}
}

Expand Down Expand Up @@ -803,17 +808,19 @@ impl ConnectionHandler for KademliaHandler {
match (remote_supports_our_kademlia_protocols, self.protocol_status) {
(true, ProtocolStatus::Confirmed | ProtocolStatus::Reported) => {}
(true, _) => {
log::info!(
"Remote {} now supports our kademlia protocol",
self.remote_peer_id
log::debug!(
"Remote {} now supports our kademlia protocol. {:?}",
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
self.remote_peer_id,
self.connection_id,
);

self.protocol_status = ProtocolStatus::Confirmed;
}
(false, ProtocolStatus::Confirmed | ProtocolStatus::Reported) => {
log::info!(
"Remote {} no longer supports our kademlia protocol",
self.remote_peer_id
log::debug!(
"Remote {} no longer supports our kademlia protocol. {:?}",
self.remote_peer_id,
self.connection_id,
);

self.protocol_status = ProtocolStatus::NotSupported;
Expand Down