aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/peer/inbound.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-29 04:34:59 +0000
committertv <tv@krebsco.de>2026-11-29 04:34:59 +0000
commita363c9958788dc648828410126f0f93c0c9bee5f (patch)
tree29b61cd65b9992ba2b3b7729ecceafce8a30d196 /src/swarm/peer/inbound.rs
parent2a475153b715c954935ae46d3773ffbf3d007f03 (diff)
wire: version 53, what is the document's as bytes, and the kind in handshakes
Spoken beside 52 (OLDEST), so a swarm upgrades node by node: a node writes each peer the newest version both speak. From 53 on (wire::KINDS, wire::kinds), what is a document's kind's goes as bytes the wire carries and doesn't read: a SYNC's body, with whether it is taken as delivered, and what vouches for what it carries; where a STATUS says its sender stands; what a BLOB request asks for in bulk; a BLOB is of a unit or of what is offered in bulk, by their names. Automerge's bytes are what 52 carries in the messages' own fields. HELLO and HELLO_REPLY say the kind of the sender's document (document::KIND, automerge) from 53 on; one in 52 says none and is of that kind. A peer whose document is of another kind is refused in the handshake, saying so. The bytes of 52 stay as golden_bytes has them; golden_bytes_of_kinds has those of 53. scripts/wire-check v0.0.1: its nodes and this tree's talk.
Diffstat (limited to 'src/swarm/peer/inbound.rs')
-rw-r--r--src/swarm/peer/inbound.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/swarm/peer/inbound.rs b/src/swarm/peer/inbound.rs
index e23ec14..a558ded 100644
--- a/src/swarm/peer/inbound.rs
+++ b/src/swarm/peer/inbound.rs
@@ -108,6 +108,20 @@ pub(crate) async fn handle_message(
return Ok(());
}
+ // Its document's kind: another than ours has nothing ours takes.
+ let kind = match &message {
+ ParsedMessage::Hello(hello) => Some(&hello.kind),
+ ParsedMessage::HelloReply(reply) => Some(&reply.kind),
+ _ => None,
+ };
+ if let Some(theirs) = kind.filter(|kind| *kind != crate::document::KIND) {
+ anyhow::bail!(
+ "{peer} holds a document of another kind ({theirs}; this node's is {}): they sync \
+ nothing; a release that knows the kind does",
+ crate::document::KIND
+ );
+ }
+
// The root its document starts from: another than ours, of our epoch, is another
// history; what a joiner takes as its root follows those named (`swarm::roots`).
match &message {