aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/sync.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 13:27:22 +0100
committertv <tv@krebsco.de>2026-10-31 13:27:22 +0100
commit36ffffb89b1dfeca0163b6ecd9c46239aca6465e (patch)
tree2a7f4a5816b0efb517956ef208d7ec3ef1b4a5c3 /src/swarm/sync.rs
parentf273b1a07e0ea78fb5b91d7916f596db899ab884 (diff)
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.
Diffstat (limited to 'src/swarm/sync.rs')
-rw-r--r--src/swarm/sync.rs5
1 files changed, 2 insertions, 3 deletions
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<Option<(bool, bool)>> {
// 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