From 09f2dfd083c4fcdce4c5ca7376353906eb025c42 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 18:18:29 +0200 Subject: put remake content into blobs --- src/transport/mod.rs | 6 ++++++ src/transport/mycelium.rs | 3 +++ 2 files changed, 9 insertions(+) (limited to 'src/transport') diff --git a/src/transport/mod.rs b/src/transport/mod.rs index c96b053..c5769ca 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -109,12 +109,18 @@ pub enum ParsedMessage { pub enum BlobId { /// An Automerge change, by its hash: e.g. an epoch's snapshot change. Change(ChangeHash), + /// Bytes by their BLAKE3 hash: e.g. the content of a remake. + Content([u8; 32]), } impl std::fmt::Display for BlobId { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { BlobId::Change(hash) => write!(f, "change:{hash}"), + BlobId::Content(hash) => { + write!(f, "content:")?; + hash.iter().try_for_each(|byte| write!(f, "{byte:02x}")) + } } } } diff --git a/src/transport/mycelium.rs b/src/transport/mycelium.rs index a8ab104..82e6016 100644 --- a/src/transport/mycelium.rs +++ b/src/transport/mycelium.rs @@ -1029,6 +1029,7 @@ pub fn bytes_to_sync_envelope(bytes: &[u8]) -> Result Result, rmp_serde::encode::Error> { let id = match msg.id { BlobId::Change(hash) => BlobIdShadow::Change(ByteBuf::from(hash.0.to_vec())), + BlobId::Content(hash) => BlobIdShadow::Content(ByteBuf::from(hash.to_vec())), }; let body = match &msg.body { BlobBody::Request { chunks } => BlobBodyShadow::Request { @@ -1098,6 +1100,7 @@ fn bytes_to_blob(bytes: &[u8]) -> Result { let shadow: BlobShadow = rmp_serde::from_slice(bytes)?; let id = match shadow.id { BlobIdShadow::Change(hash) => BlobId::Change(ChangeHash(hash32(&hash, "a change hash")?)), + BlobIdShadow::Content(hash) => BlobId::Content(hash32(&hash, "a content hash")?), }; let body = match shadow.body { BlobBodyShadow::Request { chunks } => BlobBody::Request { chunks }, -- cgit v1.3.1