From 23fdb16885d8f4d8a8d95d77d4c5daf1403e0f0f Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 12:18:52 +0100 Subject: links replies carry clock offsets --- src/transport/wire.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/transport/wire.rs') diff --git a/src/transport/wire.rs b/src/transport/wire.rs index 3daba0d..46cea4c 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 = 12; +pub(crate) const VERSION: u8 = 13; /// What the second byte of a payload says. fn tag(kind: MessageKind) -> u8 { @@ -444,6 +444,10 @@ pub(crate) fn samples() -> Vec { rtt_us: None, relayed: false, }], + clock: Some(crate::transport::paths::ClockOffset { + offset_ms: -2_500, + within_ms: 40, + }), }], }), ] @@ -618,7 +622,7 @@ mod tests { }); assert_eq!( hex(&encode(&hello).unwrap()), - format!("0c0097a5737761726d{epoch_hex}01c403010203c3{}07", run("04")) + format!("0d0097a5737761726d{epoch_hex}01c403010203c3{}07", run("04")) ); let reply = ParsedMessage::HelloReply(HelloReply { @@ -638,7 +642,7 @@ mod tests { assert_eq!( hex(&encode(&reply).unwrap()), format!( - "0c0199a5737761726d9192a17091a161{epoch_hex}01c400c2{}05{}", + "0d0199a5737761726d9192a17091a161{epoch_hex}01c400c2{}05{}", run("04"), run("06") ) @@ -654,7 +658,7 @@ mod tests { }); assert_eq!( hex(&encode(&status).unwrap()), - format!("0c03969290c400{epoch_hex}01c3c2c2") + format!("0d03969290c400{epoch_hex}01c3c2c2") ); let who = ParsedMessage::Who(IdentityProof { @@ -663,7 +667,7 @@ mod tests { }); assert_eq!( hex(&encode(&who).unwrap()), - format!("0c0692c420{}c440{}", "08".repeat(32), "09".repeat(64)) + format!("0d0692c420{}c440{}", "08".repeat(32), "09".repeat(64)) ); let ParsedMessage::Me(proof) = decode( &encode(&ParsedMessage::Me(IdentityProof { @@ -677,12 +681,12 @@ mod tests { }; assert_eq!((proof.key, proof.signature), ([8; 32], [9; 64])); - assert_eq!(hex(&encode(&ParsedMessage::Ping(7)).unwrap()), "0c0807"); + assert_eq!(hex(&encode(&ParsedMessage::Ping(7)).unwrap()), "0d0807"); let pong = ParsedMessage::Pong { nonce: u64::MAX, at: crate::clock::UnixMillis(5), }; - assert_eq!(hex(&encode(&pong).unwrap()), "0c0992cfffffffffffffffff05"); + assert_eq!(hex(&encode(&pong).unwrap()), "0d0992cfffffffffffffffff05"); let ParsedMessage::Pong { nonce, at } = decode(&[VERSION, 9, 0x92, 0x2a, 0x07]).unwrap() else { panic!("not a PONG"); -- cgit v1.3.1