From 7baed9d4c75437658f2dfa9572226b8163effaee 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 49f75dc..63e6490 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