summaryrefslogtreecommitdiffstats
path: root/src/state.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-23 22:12:20 +0200
committertv <tv@krebsco.de>2026-10-23 22:20:34 +0200
commit276f936fc8730504666fbf1c3c5b2942f9be9016 (patch)
tree3d7d7c424eee120cb49094b72f48952606509e05 /src/state.rs
parent2311d0cc57a2e0d5776b355983ca2e3f82f9980f (diff)
enrich keepalive content
Add ready and syncs_with_you flags as well as actual heads, so the peer - ready: same meaning as in the sync message - syncs_with_you: sender counts recipient as member and in same epoch - heads: allows to tell who's behind or if both sides have changes
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/state.rs b/src/state.rs
index 23892a9..72013b9 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -121,8 +121,11 @@ pub(crate) struct PeerState {
/// Epoch the peer advertised in its most recent message.
pub(crate) epoch: Option<Epoch>,
- /// Whether the peer was ready according to its most recent sync message.
+ /// Whether the peer was ready according to its most recent sync message or keepalive.
pub(crate) reports_ready: Option<bool>,
+
+ /// Whether the peer said, in its most recent keepalive, that it would sync with us.
+ pub(crate) syncs_with_us: Option<bool>,
}
/// One Automerge sync with a peer, from a reset to the next. Everything a reset must
@@ -326,6 +329,7 @@ impl PeerState {
last_resync_at: None,
epoch: None,
reports_ready: None,
+ syncs_with_us: None,
}
}
@@ -431,8 +435,8 @@ impl PeerState {
/// Self-healing check on PING/PONG. Returns true if a re-handshake should start.
pub(crate) fn needs_heal(
&mut self,
- local: &transport::HeadsDigest,
- remote: &transport::HeadsDigest,
+ local: &transport::HeadsSummary,
+ remote: &transport::HeadsSummary,
timing: &Timing,
now: Instant,
) -> bool {
@@ -792,11 +796,11 @@ impl AppState {
}
}
- let keepalive = crate::swarm::peer::local_keepalive(self).await;
for id in announce {
+ let keepalive = crate::swarm::peer::local_keepalive(self, id).await;
if let Err(error) = self
.transport
- .send_message(id, &transport::ParsedMessage::Ping(keepalive.clone()))
+ .send_message(id, &transport::ParsedMessage::Ping(keepalive))
.await
{
debug!(peer = %id, error = %format!("{error:#}"), "Epoch announcement failed");