diff options
| author | tv <tv@krebsco.de> | 2026-11-29 15:06:04 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-29 15:06:04 +0000 |
| commit | 8cdde74fcdcf31414da0d22222d2cc338df20fa1 (patch) | |
| tree | 37911374599ed825fa3264c8e99ae830cec843fc /src/transport/mod.rs | |
| parent | a3af68fafee80b3eef493e8b041e21352e547da2 (diff) | |
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.
Diffstat (limited to 'src/transport/mod.rs')
| -rw-r--r-- | src/transport/mod.rs | 14 |
1 files changed, 13 insertions, 1 deletions
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<ChangeHash>, }, + /// 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<u8>), } /// 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<u8>), } /// 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(), } } } |
