From 487690bb0fb63c5dcc80d009632bd9430d946af1 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 23 Oct 2026 22:56:30 +0200 Subject: both sides may open sync after reset Ready nodes will leave the first message to the pear that isn't ready. Hello and hello reply now carry ready, so readiness is known from the very first contact, before any sync. Together with the sync messages and keepalives, reports_ready is always current. After epoch switch, pings go to everyone except ready members already on the new epoch, these learn from the lagging peer's opening. --- src/transport/mycelium.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/transport/mycelium.rs') diff --git a/src/transport/mycelium.rs b/src/transport/mycelium.rs index 2406312..4a8a5a5 100644 --- a/src/transport/mycelium.rs +++ b/src/transport/mycelium.rs @@ -830,6 +830,7 @@ pub struct HelloRequestShadow { swarm_id: Option, epoch: EpochShadow, auth: ByteBuf, + ready: bool, } #[derive(Serialize, Deserialize)] @@ -842,6 +843,7 @@ pub struct HelloReplyShadow<'a> { epoch: EpochShadow, #[serde(default)] auth: ByteBuf, + ready: bool, } #[derive(Serialize, Deserialize)] @@ -891,6 +893,7 @@ pub fn hello_request_to_bytes(msg: &HelloRequest) -> Result, rmp_serde:: swarm_id: msg.swarm_id.clone(), epoch: epoch_to_shadow(&msg.epoch), auth: ByteBuf::from(msg.auth.clone()), + ready: msg.ready, }) } pub fn bytes_to_hello_request(bytes: &[u8]) -> Result { @@ -899,6 +902,7 @@ pub fn bytes_to_hello_request(bytes: &[u8]) -> Result Result, rmp_serde::enco peers: msg.peers.clone(), // Vec must be cloned for serialization wrapper matching epoch: epoch_to_shadow(&msg.epoch), auth: ByteBuf::from(msg.auth.clone()), + ready: msg.ready, }; rmp_serde::to_vec(&shadow) } @@ -919,6 +924,7 @@ pub fn bytes_to_hello_reply(bytes: &[u8]) -> Result peers: shadow.peers, epoch: epoch_from_shadow(shadow.epoch)?, auth: shadow.auth.into_vec(), + ready: shadow.ready, }) } -- cgit v1.3.1