summaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-23 22:56:30 +0200
committertv <tv@krebsco.de>2026-10-23 23:08:00 +0200
commit487690bb0fb63c5dcc80d009632bd9430d946af1 (patch)
treefad60f7a09d681e6d4e2641adb04c54e601bbd75 /src/transport
parentd1ea53c3b9c24fc07435b12ae46d8b519ffddba9 (diff)
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.
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/mod.rs4
-rw-r--r--src/transport/mycelium.rs6
2 files changed, 10 insertions, 0 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index d96b059..83c4e8d 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -118,6 +118,8 @@ pub struct HelloRequest {
pub epoch: Epoch,
/// Proof of the swarm key (`swarm::auth`); empty without one.
pub auth: Vec<u8>,
+ /// The sender is ready (same meaning as `SyncEnvelope::ready`).
+ pub ready: bool,
}
#[derive(Debug, Clone)]
@@ -127,6 +129,8 @@ pub struct HelloReply {
pub epoch: Epoch,
/// Proof of the swarm key (`swarm::auth`); empty without one.
pub auth: Vec<u8>,
+ /// The sender is ready.
+ pub ready: bool,
}
#[derive(Debug, Clone)]
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<String>,
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<Vec<u8>, 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<HelloRequest, TransportError> {
@@ -899,6 +902,7 @@ pub fn bytes_to_hello_request(bytes: &[u8]) -> Result<HelloRequest, TransportErr
swarm_id: shadow.swarm_id,
epoch: epoch_from_shadow(shadow.epoch)?,
auth: shadow.auth.into_vec(),
+ ready: shadow.ready,
})
}
@@ -909,6 +913,7 @@ pub fn hello_reply_to_bytes(msg: &HelloReply) -> Result<Vec<u8>, 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<HelloReply, TransportError>
peers: shadow.peers,
epoch: epoch_from_shadow(shadow.epoch)?,
auth: shadow.auth.into_vec(),
+ ready: shadow.ready,
})
}