From a098d7e5eaf486fe3d9813f690745619121bac65 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 22 Oct 2026 21:55:36 +0200 Subject: don't resend sync messages to up-to-date peers When an sync messages arrives and automerge has nothing to say about it, then no reply is generated. With c9279e4 it was assumed that every sync message gets an answer, so missing replies caused unnecessary resends. Now a reply is only awaited if the peer's last reported heads differ from ours. If the peer's heads become equal through a third peer without replying, the waiting will also abort if a ping or pong showss the same heads digest on both sides. --- src/state.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index 667fff1..9c3b569 100644 --- a/src/state.rs +++ b/src/state.rs @@ -178,6 +178,12 @@ impl PeerState { } } + /// Keepalives show both documents are the same: stop waiting for an answer. + pub(crate) fn sync_in_step(&mut self) { + self.sync_reply = None; + self.sync_reply_timeout = SYNC_REPLY_TIMEOUT; + } + /// The peer answered. pub(crate) fn sync_reply_received(&mut self) { self.sync_reply = None; -- cgit v1.3.1