From 4e53e152f83ecb88fa162e0a18e6832df5a38fef Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 5 Nov 2026 05:38:20 +0100 Subject: round trips in trees --- src/transport/libp2p/tests.rs | 1 + src/transport/mod.rs | 5 +++++ src/transport/mycelium/mod.rs | 1 + src/transport/paths.rs | 1 + src/transport/sim.rs | 1 + src/transport/wire.rs | 8 ++++++-- 6 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/transport') diff --git a/src/transport/libp2p/tests.rs b/src/transport/libp2p/tests.rs index 9f013c2..5d08190 100644 --- a/src/transport/libp2p/tests.rs +++ b/src/transport/libp2p/tests.rs @@ -61,6 +61,7 @@ fn status() -> ParsedMessage { leaving: false, announcing: false, reaches: None, + round_trips: None, }) } diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 85f69f5..e81adfb 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -210,6 +210,11 @@ pub(crate) struct Status { /// of the members it has an active session with that answer, sorted. In keepalive STATUSes and /// their replies, and when it changed; not in announcements of heads (None). pub(crate) reaches: Option>, + /// The round trip to each member in `reaches`, in its order, as a bucket + /// (`swarm::rtt::bucket`): which of a member's possible parents in a writer's tree + /// is the faster (`swarm::tree`). With `reaches`; None otherwise. + #[serde(with = "serde_bytes")] + pub(crate) round_trips: Option>, } /// Cheap to clone: large parts are shared (`bytes::Bytes`). diff --git a/src/transport/mycelium/mod.rs b/src/transport/mycelium/mod.rs index 3552edf..7bae0a7 100644 --- a/src/transport/mycelium/mod.rs +++ b/src/transport/mycelium/mod.rs @@ -719,6 +719,7 @@ mod tests { leaving: false, announcing: false, reaches: None, + round_trips: None, }; let payload = wire::encode(&ParsedMessage::StatusReply(status.clone())).unwrap(); // Mycelium's message data: a length byte, the topic, then our payload. diff --git a/src/transport/paths.rs b/src/transport/paths.rs index 8c03b1f..aca0684 100644 --- a/src/transport/paths.rs +++ b/src/transport/paths.rs @@ -1619,6 +1619,7 @@ mod tests { leaving: false, announcing: false, reaches: None, + round_trips: None, }) } diff --git a/src/transport/sim.rs b/src/transport/sim.rs index 12f3885..06f15f6 100644 --- a/src/transport/sim.rs +++ b/src/transport/sim.rs @@ -434,6 +434,7 @@ mod tests { leaving: false, announcing: false, reaches: None, + round_trips: None, }) } diff --git a/src/transport/wire.rs b/src/transport/wire.rs index 580712e..769545c 100644 --- a/src/transport/wire.rs +++ b/src/transport/wire.rs @@ -14,7 +14,7 @@ use super::{EncodedMessage, MessageKind, ParsedMessage}; /// The wire format's version, the first byte of every payload. Bump it with every change /// to a message type or a codec (`golden_bytes` fails then). -pub(crate) const VERSION: u8 = 34; +pub(crate) const VERSION: u8 = 35; /// What the second byte of a payload says. fn tag(kind: MessageKind) -> u8 { @@ -384,6 +384,7 @@ pub(crate) fn samples() -> Vec { leaving: false, announcing: false, reaches: None, + round_trips: None, }; let proof = IdentityProof { key: [8; 32], @@ -570,6 +571,7 @@ mod tests { leaving: false, announcing: false, reaches: None, + round_trips: None, }; let decoded = decode(&encode(&ParsedMessage::StatusReply(status.clone())).unwrap()).unwrap(); @@ -595,6 +597,7 @@ mod tests { leaving: false, announcing: false, reaches: None, + round_trips: None, }; assert!(decode(&encode(&ParsedMessage::Status(status)).unwrap()).is_err()); } @@ -695,10 +698,11 @@ mod tests { leaving: false, announcing: true, reaches: None, + round_trips: None, }); assert_eq!( hex(&encode(&status).unwrap()), - format!("{v}03989290c400{epoch_hex}01c3c2c2c3c0") + format!("{v}03999290c400{epoch_hex}01c3c2c2c3c0c0") ); let who = ParsedMessage::Who(IdentityProof { -- cgit v1.3.1