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 | a216c65c48f6b662ce083873d6e344fbee1c556b (patch) | |
| tree | f7cc9d290cef8311127adea9b818b3fd2d3aa67b /src/transport/mod.rs | |
| parent | 1781243546af0a90ed1d572a0581dc450ef01d85 (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 |
