aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/sync.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-03 05:21:25 +0100
committertv <tv@krebsco.de>2026-11-03 05:21:25 +0100
commit8366f7c5de474753dbfbf88431917e79c15e5389 (patch)
tree8c3ed8cca74760ff98b58264843765a3d8e65d3b /src/swarm/sync.rs
parent96d7744dd29a3c783b43a7a6697af7d5d5719a10 (diff)
replace eager links by trees
Diffstat (limited to 'src/swarm/sync.rs')
-rw-r--r--src/swarm/sync.rs18
1 files changed, 5 insertions, 13 deletions
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<Option<(bool, bool, bool)>> {
+ // 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 = 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;