From 5fd686dcd8ddfbdf276c044e5acf03f744e03193 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 27 Oct 2026 01:01:51 +0100 Subject: introduce addresses --- src/transport/wire.rs | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src/transport/wire.rs') diff --git a/src/transport/wire.rs b/src/transport/wire.rs index 009380f..ceeaf87 100644 --- a/src/transport/wire.rs +++ b/src/transport/wire.rs @@ -14,7 +14,7 @@ use super::{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 = 3; +pub(crate) const VERSION: u8 = 4; /// What the second byte of a payload says. fn tag(kind: MessageKind) -> u8 { @@ -300,7 +300,7 @@ mod tests { use crate::document::replica::Epoch; use crate::transport::{ BlobBody, BlobId, BlobMessage, HeadsSummary, HelloReply, HelloRequest, Keepalive, - MAX_LISTED_HEADS, + ListedPeer, MAX_LISTED_HEADS, }; use automerge::ChangeHash; @@ -330,7 +330,10 @@ mod tests { let reply = ParsedMessage::HelloReply(HelloReply { swarm_id: "swarm".into(), - peers: vec!["p".into()], + peers: vec![ListedPeer { + id: "p".into(), + addresses: vec!["a".into()], + }], epoch, epoch_seq: 1, auth: Vec::new(), @@ -342,7 +345,13 @@ mod tests { let ParsedMessage::HelloReply(decoded) = decode(&encode(&reply).unwrap()).unwrap() else { panic!("not a HELLO_REPLY"); }; - assert_eq!(decoded.peers, vec!["p".to_owned()]); + assert_eq!( + decoded.peers, + vec![ListedPeer { + id: "p".into(), + addresses: vec!["a".into()], + }] + ); assert_eq!(decoded.away_ms, Some(5)); assert_eq!(decoded.sender_run_id, [6; 16]); } @@ -438,12 +447,15 @@ mod tests { }); assert_eq!( hex(&encode(&hello).unwrap()), - format!("030097a5737761726d{epoch_hex}01c403010203c3{}07", run("04")) + format!("040097a5737761726d{epoch_hex}01c403010203c3{}07", run("04")) ); let reply = ParsedMessage::HelloReply(HelloReply { swarm_id: "swarm".into(), - peers: vec!["p".into()], + peers: vec![ListedPeer { + id: "p".into(), + addresses: vec!["a".into()], + }], epoch, epoch_seq: 1, auth: Vec::new(), @@ -455,7 +467,7 @@ mod tests { assert_eq!( hex(&encode(&reply).unwrap()), format!( - "030199a5737761726d91a170{epoch_hex}01c400c2{}05{}", + "040199a5737761726d9192a17091a161{epoch_hex}01c400c2{}05{}", run("04"), run("06") ) @@ -470,7 +482,7 @@ mod tests { }); assert_eq!( hex(&encode(&ping).unwrap()), - format!("0303959290c400{epoch_hex}01c3c2") + format!("0403959290c400{epoch_hex}01c3c2") ); } } -- cgit v1.3.1