diff options
Diffstat (limited to 'src/peer.rs')
| -rw-r--r-- | src/peer.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/peer.rs b/src/peer.rs index 015b5ff..50460b0 100644 --- a/src/peer.rs +++ b/src/peer.rs @@ -108,7 +108,7 @@ fn heads_digest(doc: &mut AutoCommit) -> transport::HeadsDigest { hasher.finalize().into() } -async fn local_keepalive(state: &AppState) -> transport::Keepalive { +pub(crate) async fn local_keepalive(state: &AppState) -> transport::Keepalive { // AutoCommit::get_heads takes &mut self (it closes the pending transaction). // Digest and epoch come from the same locked replica, so they always match. let mut replica = state.doc.write().await; @@ -517,8 +517,11 @@ async fn observe_peer_epoch(state: &AppState, peer: &str, remote: Epoch) -> bool let mut peer_state = peer_state_mutex.lock().await; let previous = peer_state.epoch.replace(remote); if previous.is_some_and(|previous| previous != remote) { - // The peer switched documents; our sync state describes its old one. + // The peer switched documents; our sync state describes its old one. Count + // the restart as sync activity, so the keepalive heal doesn't re-handshake + // (resetting both sides again) while this fresh sync is under way. peer_state.reset_sync(); + peer_state.last_sync_rx = Some(Instant::now()); } previous }; |
