summaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-23 22:53:16 +0200
committertv <tv@krebsco.de>2026-10-23 22:54:16 +0200
commitd1ea53c3b9c24fc07435b12ae46d8b519ffddba9 (patch)
treecfbb563a2a5e46cc636e34afae2fe3d482bc092c /src/transport
parent42b2b644815a2b7f29eb078eb515820368121f89 (diff)
perform handshake in one round trip
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/mod.rs3
-rw-r--r--src/transport/mycelium.rs5
2 files changed, 6 insertions, 2 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs
index d7e7135..d96b059 100644
--- a/src/transport/mod.rs
+++ b/src/transport/mod.rs
@@ -112,6 +112,9 @@ impl ParsedMessage {
#[derive(Debug, Clone)]
pub struct HelloRequest {
+ /// The sender's swarm, if it knows it (a new node doesn't yet). A receiver in
+ /// another swarm doesn't answer.
+ pub swarm_id: Option<String>,
pub epoch: Epoch,
/// Proof of the swarm key (`swarm::auth`); empty without one.
pub auth: Vec<u8>,
diff --git a/src/transport/mycelium.rs b/src/transport/mycelium.rs
index 2683f82..2406312 100644
--- a/src/transport/mycelium.rs
+++ b/src/transport/mycelium.rs
@@ -827,9 +827,8 @@ fn bytes_to_keepalive(bytes: &[u8]) -> Result<Keepalive, TransportError> {
#[derive(Serialize, Deserialize)]
pub struct HelloRequestShadow {
- #[serde(default)]
+ swarm_id: Option<String>,
epoch: EpochShadow,
- #[serde(default)]
auth: ByteBuf,
}
@@ -889,6 +888,7 @@ mod automerge_msg_codec {
// --- HelloRequest ---
pub fn hello_request_to_bytes(msg: &HelloRequest) -> Result<Vec<u8>, rmp_serde::encode::Error> {
rmp_serde::to_vec(&HelloRequestShadow {
+ swarm_id: msg.swarm_id.clone(),
epoch: epoch_to_shadow(&msg.epoch),
auth: ByteBuf::from(msg.auth.clone()),
})
@@ -896,6 +896,7 @@ pub fn hello_request_to_bytes(msg: &HelloRequest) -> Result<Vec<u8>, rmp_serde::
pub fn bytes_to_hello_request(bytes: &[u8]) -> Result<HelloRequest, TransportError> {
let shadow: HelloRequestShadow = rmp_serde::from_slice(bytes)?;
Ok(HelloRequest {
+ swarm_id: shadow.swarm_id,
epoch: epoch_from_shadow(shadow.epoch)?,
auth: shadow.auth.into_vec(),
})