diff options
| author | tv <tv@krebsco.de> | 2026-10-31 06:50:07 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-31 06:50:07 +0100 |
| commit | bef59234ea3e219d80373d760601ba40f4789a47 (patch) | |
| tree | d97263079b725ecaad1197e0debaf00713422394 /src/transport/mod.rs | |
| parent | babf3e24339542bea5434bc3efdf30f8d0181281 (diff) | |
pong carries time
Diffstat (limited to 'src/transport/mod.rs')
| -rw-r--r-- | src/transport/mod.rs | 14 |
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 |
