aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/sync.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-05 16:41:38 +0100
committertv <tv@krebsco.de>2026-11-05 16:41:38 +0100
commit565b27269b598de3e337d732525b2a171a30cb5e (patch)
tree7fa7ca968c8a23bb434684d9db6ce5adcd2351f3 /src/swarm/sync.rs
parentb3e102076666e515c77c50f0eb1150f44f0874e5 (diff)
answering behind counted
Diffstat (limited to 'src/swarm/sync.rs')
-rw-r--r--src/swarm/sync.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/swarm/sync.rs b/src/swarm/sync.rs
index c969678..5100b98 100644
--- a/src/swarm/sync.rs
+++ b/src/swarm/sync.rs
@@ -603,10 +603,15 @@ pub(crate) async fn handle_sync(
let heads_after = replica.heads().to_vec();
if delivered {
// Level with the sender now, which takes the message as delivered:
- // nothing to answer (`SyncSession::answered_as_delivered`).
- peer_state
+ // nothing to answer (`SyncSession::answered_as_delivered`). Unless it is
+ // behind us: then the answer brings it what it lacks.
+ let behind = peer_state.sync.peer_behind(&replica.doc, &heads_after);
+ let answered = peer_state
.sync
.answered_as_delivered(&replica.doc, &heads_after);
+ if behind && !answered {
+ stats.answering_behind();
+ }
}
stats.heads_seen(heads_after.len());
let changed = heads_after != heads_before;