From 8cdde74fcdcf31414da0d22222d2cc338df20fa1 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 15:06:04 +0000 Subject: wire: what another kind of document says, in a SYNC's body and a STATUS's stamp From version 53 on, beside Automerge's (SyncBody::Kind, HeadsSummary::Kind): a SYNC's body is one more of its shapes, another kind's bytes; a STATUS's stamp is another kind's bytes after a byte no Automerge stamp begins with. Nothing version 53 said changes, and version 52 says neither (WireError::OtherKind). Two stamps of another kind are the same where their bytes are. A node holding an Automerge document passes over a body of another kind: a peer holding one isn't let near it. --- src/transport/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/transport/mod.rs') diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 61abe9c..4189890 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -114,6 +114,9 @@ pub(crate) enum HeadsSummary { /// of starting the sync over to find out what it lacks. sample: Vec, }, + /// Where a document of another kind than Automerge's stands, as that kind's bytes + /// (`docs/document.md`, Passing on): neither heads nor a digest of any. + Kind(Vec), } /// Where the next sample starts (`HeadsSummary::of`). @@ -144,6 +147,7 @@ impl HeadsSummary { match self { Self::Heads(heads) => digest_of(heads), Self::Digest { digest, .. } => *digest, + Self::Kind(bytes) => Sha256::digest(bytes).into(), } } @@ -151,7 +155,7 @@ impl HeadsSummary { pub(crate) fn heads(&self) -> Option<&[ChangeHash]> { match self { Self::Heads(heads) => Some(heads), - Self::Digest { .. } => None, + Self::Digest { .. } | Self::Kind(_) => None, } } @@ -160,6 +164,7 @@ impl HeadsSummary { match self { Self::Heads(heads) => heads, Self::Digest { sample, .. } => sample, + Self::Kind(_) => &[], } } } @@ -845,6 +850,9 @@ pub(crate) enum SyncBody { /// Instead of a message too large to send in one piece: fetch these changes as a /// blob (`BlobId::Delta`), then sync on. Delta(DeltaSpec), + /// What a document of another kind than Automerge's says, as that kind's bytes + /// (`docs/document.md`, Passing on). + Kind(#[serde(with = "serde_bytes")] Vec), } /// The changes in the history of `to` but not of `from`: what a peer at `from` lacks of @@ -934,6 +942,10 @@ impl std::fmt::Debug for SyncBody { ) .finish(), Self::Delta(spec) => f.debug_tuple("Delta").field(spec).finish(), + Self::Kind(bytes) => f + .debug_tuple("Kind") + .field(&format!("{} bytes", bytes.len())) + .finish(), } } } -- cgit v1.3.1