From 8366f7c5de474753dbfbf88431917e79c15e5389 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 3 Nov 2026 05:21:25 +0100 Subject: replace eager links by trees --- src/swarm/sync.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/swarm/sync.rs') diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs index 403e0c1..187dacc 100644 --- a/src/swarm/sync.rs +++ b/src/swarm/sync.rs @@ -376,12 +376,11 @@ pub(crate) async fn handle_sync( let clock = Arc::clone(&state.clock); let ahead_ms = state.clock_ahead_ms.load(Ordering::Relaxed); - // Some((caught_up, heads changed, a duplicate)) when applied, None when the - // message belongs to another epoch. - tokio::task::spawn_blocking(move || -> Result> { + // Some((caught_up, heads changed)) when applied, None when the message belongs + // to another epoch. + tokio::task::spawn_blocking(move || -> Result> { // Before the lock: decoding a large message takes a while. let message = crate::document::sync::decode(&message)?; - let carries_changes = message.carries_changes(); let mut replica = doc.blocking_write(); // Authoritative check, under the same lock as the apply: the document may @@ -411,9 +410,6 @@ pub(crate) async fn handle_sync( let heads_after = replica.heads().to_vec(); stats.heads_seen(heads_after.len()); let changed = heads_after != heads_before; - // Changes we had already, over a link we asked to be eager: the link isn't - // needed (`relay::prune`). - let duplicate = carries_changes && !changed && peer_state.eager_from; if changed && measure_propagation { // Now by the peers' clocks (their median): this node's own clock skew // doesn't count; the writer's still does. @@ -434,14 +430,13 @@ pub(crate) async fn handle_sync( // before it registered itself). check_caught_up && from_ready && peer_state.sync.have_all_theirs(&replica.doc), changed, - duplicate, ))) }) .await .context("Sync task panicked")?? }; - let Some((caught_up, changed, duplicate)) = applied else { + let Some((caught_up, changed)) = applied else { debug!(peer = %peer, epoch = %epoch_label, "Dropped sync message from another epoch"); return Ok(()); }; @@ -460,10 +455,7 @@ pub(crate) async fn handle_sync( state.notify_store_changed(); - crate::swarm::relay::pulled(state, peer, changed).await; - if duplicate { - crate::swarm::relay::prune(state, peer).await; - } + crate::swarm::relay::pulled(state, peer); // Caught up: our other neighbours may lack what the source had. if changed || just_caught_up { crate::swarm::relay::announce(state, peer, writer.filter(|_| changed)).await; -- cgit v1.3.1