From 36ffffb89b1dfeca0163b6ecd9c46239aca6465e Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 31 Oct 2026 13:27:22 +0100 Subject: sync messages are bytes outside the session SyncPayload is now an opaque byte container in transport. SyncSession::generate returns the encoded payload, state::decode_sync(&payload) decodes it off the document lock (as before), and receive takes the decoded message, which is a type only the session can open. transport/mod.rs no longer imports Automerge. --- src/swarm/sync.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/swarm') diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index 18c017c..772932d 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -145,8 +145,7 @@ async fn deliver_sync_to_peer(state: &AppState, peer: &str) -> Result<()> { peer_state .sync .generate(&mut replica.doc, Instant::now(), bytes_before); - let body = message.map(|message| { - let payload = transport::SyncPayload::encode(message); + let body = message.map(|payload| { if payload.0.len() <= delta_threshold { return transport::SyncBody::Message(payload); } @@ -356,7 +355,7 @@ pub(crate) async fn handle_sync( // to another epoch. tokio::task::spawn_blocking(move || -> Result> { // Before the lock: decoding a large message takes a while. - let message = message.decode()?; + let message = crate::state::decode_sync(&message)?; let mut replica = doc.blocking_write(); // Authoritative check, under the same lock as the apply: the document may -- cgit v1.3.1