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

feat(node): add marker for a network connection timeout #577

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion sn_networking/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ impl SwarmDriver {
peer_id,
connection_id,
} => trace!("Dialing {peer_id:?} on {connection_id:?}"),

SwarmEvent::Behaviour(NodeEvent::Autonat(event)) => match event {
autonat::Event::InboundProbe(e) => debug!("AutoNAT inbound probe: {e:?}"),
autonat::Event::OutboundProbe(e) => debug!("AutoNAT outbound probe: {e:?}"),
Expand Down
11 changes: 7 additions & 4 deletions sn_node/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,15 @@ impl Node {
}
}
_ = tokio::time::sleep(inactivity_timeout) => {
let random_target = NetworkAddress::from_peer(PeerId::random());

Marker::NoNetworkActivity( inactivity_timeout ).log();
let random_target = NetworkAddress::from_peer(PeerId::random());
debug!("No network activity in the past {inactivity_timeout:?}, performing a random get_closest query to target: {random_target:?}");
if let Ok(closest) = network_clone.node_get_closest_peers(&random_target).await {
debug!("Network inactivity: get_closest returned {closest:?}");
match network_clone.node_get_closest_peers(&random_target).await {
Ok(closest) => debug!("Network inactivity: get_closest returned {closest:?}"),
Err(e) => {
warn!("get_closest query failed after network inactivity timeout - check your connection: {}", e);
Marker::OperationFailedAfterNetworkInactivityTimeout.log();
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions sn_node/src/log_markers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ use strum::Display;
/// Changing these log markers is a breaking change.
#[derive(Debug, Clone, Display)]
pub enum Marker<'a> {
/// An operation failed after timing out due to a period of no network activity
OperationFailedAfterNetworkInactivityTimeout,

/// The node has started
NodeConnectedToNetwork,

Expand Down