aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/mod.rs')
-rw-r--r--src/transport/mod.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index 903dd07..9a82cbe 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -219,8 +219,12 @@ pub(crate) enum ParsedMessage {
Me(IdentityProof),
/// Asks for a PONG with this nonce, over the same path (`transport::paths`).
Ping(u64),
- /// Answers a PING.
- Pong(u64),
+ /// Answers a PING: its nonce, and when it was answered by the answerer's clock
+ /// (`at`), for comparing clocks (`transport::paths`).
+ Pong {
+ nonce: u64,
+ at: crate::clock::UnixMillis,
+ },
/// Asks a member how it is linked to its peers, for a map of the swarm
/// (`swarm::links`).
Links(LinksRequest),
@@ -367,7 +371,7 @@ impl ParsedMessage {
ParsedMessage::Who(_) => MessageKind::Who,
ParsedMessage::Me(_) => MessageKind::Me,
ParsedMessage::Ping(_) => MessageKind::Ping,
- ParsedMessage::Pong(_) => MessageKind::Pong,
+ ParsedMessage::Pong { .. } => MessageKind::Pong,
ParsedMessage::Links(_) => MessageKind::Links,
ParsedMessage::LinksReply(_) => MessageKind::LinksReply,
}
@@ -389,7 +393,7 @@ impl ParsedMessage {
ParsedMessage::Who(_)
| ParsedMessage::Me(_)
| ParsedMessage::Ping(_)
- | ParsedMessage::Pong(_) => None,
+ | ParsedMessage::Pong { .. } => None,
}
}
}
@@ -735,7 +739,7 @@ impl<T: std::fmt::Display> std::fmt::Display for Addressed<T> {
/// consumer hands them on as soon as they are read (`hand_on_probe`), not after the
/// messages read before them are handled (which can take a while: sync).
pub(crate) fn is_probe(message: &ParsedMessage) -> bool {
- matches!(message, ParsedMessage::Ping(_) | ParsedMessage::Pong(_))
+ matches!(message, ParsedMessage::Ping(_) | ParsedMessage::Pong { .. })
}
/// Hands a PING or PONG (`is_probe`) to `handler` in a task of its own; `scheme` is the