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.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;