summaryrefslogtreecommitdiffstats
path: root/src/swarm
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm')
-rw-r--r--src/swarm/sync.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index 0fbff05..ca54fae 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -159,7 +159,7 @@ async fn deliver_sync_to_peer(state: &AppState, peer: &str) -> Result<()> {
swarm_id,
epoch,
epoch_seq,
- message,
+ message: transport::SyncPayload::encode(message),
ready,
};
let encoded = transport
@@ -336,6 +336,8 @@ pub(crate) async fn handle_sync(
// Some((caught_up, heads changed)) when applied, None when the message belongs
// 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 mut replica = doc.blocking_write();
// Authoritative check, under the same lock as the apply: the document may