aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/relay.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/swarm/relay.rs')
-rw-r--r--src/swarm/relay.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/swarm/relay.rs b/src/swarm/relay.rs
index a8e3d57..bee8687 100644
--- a/src/swarm/relay.rs
+++ b/src/swarm/relay.rs
@@ -333,14 +333,19 @@ pub(crate) async fn lacks(state: &AppState, heads: &HeadsSummary) -> bool {
/// end (`PeerState::pull_pending`).
pub(crate) async fn pull_after_grace(state: &AppState, peer: &str, remote: &transport::Status) {
if HeadsSummary::of(state.stamp.borrow().heads.to_vec()) != remote.heads {
- let grace = state
- .lock_rtt()
- .effective(peer, Instant::now(), state.timing.rtt_fresh_for())
- .map(|rtt| rtt.min(PULL_GRACE_MAX));
- if let Some(grace) = grace
- && lacks(state, &remote.heads).await
- {
- tokio::time::sleep(grace).await;
+ let missing = {
+ let replica = state.doc.read().await;
+ crate::document::changes::missing(&replica.doc, remote.heads.listed())
+ };
+ if !missing.is_empty() {
+ state.dissemination.announced(peer, &missing);
+ let grace = state
+ .lock_rtt()
+ .effective(peer, Instant::now(), state.timing.rtt_fresh_for())
+ .map(|rtt| rtt.min(PULL_GRACE_MAX));
+ if let Some(grace) = grace {
+ tokio::time::sleep(grace).await;
+ }
}
}
let latest = match state.get_peer_state(peer).await {