aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/sync.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/sync.rs')
-rw-r--r--src/swarm/sync.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index 0f607e7..aea6a0b 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -471,8 +471,7 @@ pub(crate) async fn handle_sync(
let writer = envelope.writer;
let delivered = envelope.delivered;
// Changes pushed along a tree (`SyncBody::Changes`): their heads and bytes, made
- // into the Automerge message that would have brought them once the document's lock
- // is held (`Received::pushed`).
+ // into the Automerge message that would have brought them (`Received::pushed`).
let (payload, deflated, pushed) = match envelope.body {
transport::SyncBody::Message(payload) => (payload, false, None),
transport::SyncBody::Deflated(payload) => (payload, true, None),
@@ -537,12 +536,13 @@ pub(crate) async fn handle_sync(
} else {
message
};
- let (payload_len, decoded) = match &pushed {
- Some((_, _, len)) => (*len, None),
- None => (
- message.0.len(),
- Some(crate::document::sync::decode(&message)?),
+ let (payload_len, message) = match pushed {
+ Some((heads, changes, len)) => (
+ len,
+ crate::document::sync::Received::pushed(heads, changes)
+ .context("Pushed changes that don't decode")?,
),
+ None => (message.0.len(), crate::document::sync::decode(&message)?),
};
stats.sync_received(payload_len);
let mut replica = doc.blocking_write();
@@ -552,13 +552,6 @@ pub(crate) async fn handle_sync(
if replica.epoch != epoch {
return Ok(None);
}
- let message = match decoded {
- Some(message) => message,
- None => {
- let (heads, changes, _) = pushed.expect("pushed or decoded");
- crate::document::sync::Received::pushed(heads, changes)
- }
- };
let carried = message.carries_changes();
let sizes = if carried { message.sizes() } else { (0, 0) };
if carried {