aboutsummaryrefslogtreecommitdiffstats
path: root/src/state
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 03:49:56 +0100
committertv <tv@krebsco.de>2026-10-31 03:49:56 +0100
commitc21b0fdd615df754c0fa46d43600d701a5a4805c (patch)
treea412c19155de7e2b909a448c9176a64a16a69c80 /src/state
parent66c9d2b57ce3c59b2eb7e3c30d053acd1a230b51 (diff)
unify sync_on predicate
Diffstat (limited to 'src/state')
-rw-r--r--src/state/host.rs6
-rw-r--r--src/state/peer.rs8
2 files changed, 10 insertions, 4 deletions
diff --git a/src/state/host.rs b/src/state/host.rs
index ee67b80..04b328c 100644
--- a/src/state/host.rs
+++ b/src/state/host.rs
@@ -41,10 +41,8 @@ impl AppState {
let mut peer_state = peer_state_mutex.lock().await;
// What it said about syncing with us was about our old epoch.
peer_state.syncs_with_us = None;
- let gets_our_opening = !peer_state.liveness.is_dormant()
- && matches!(peer_state.standing, Standing::Member { .. })
- && peer_state.epoch == Some(local)
- && peer_state.reports_ready == Some(true);
+ let gets_our_opening =
+ peer_state.syncs_on(local) && peer_state.reports_ready == Some(true);
if !gets_our_opening {
announce.push(id);
}
diff --git a/src/state/peer.rs b/src/state/peer.rs
index dc1b0ec..95a9dc3 100644
--- a/src/state/peer.rs
+++ b/src/state/peer.rs
@@ -275,6 +275,14 @@ impl PeerState {
}
}
+ /// Whether we sync with it on `epoch`: an active member on that epoch (what our
+ /// STATUS tells it as `syncs_with_you`).
+ pub(crate) fn syncs_on(&self, epoch: Epoch) -> bool {
+ !self.liveness.is_dormant()
+ && matches!(self.standing, Standing::Member { .. })
+ && self.epoch == Some(epoch)
+ }
+
/// Whether to leave the peer out when choosing neighbours (`swarm::topology`).
pub(crate) fn is_unreachable(&self) -> bool {
self.unreachable_since.is_some()