aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/members.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 13:25:49 +0100
committertv <tv@krebsco.de>2026-11-01 13:25:49 +0100
commit9333940209c48d460a5f61b80ba827db7889f147 (patch)
treec818fcba62b052cd77934d91de66a0ba9539400a /src/swarm/members.rs
parentd5de69630cf544fd048c8376e1b51cd0e4e7c7fc (diff)
electorate window must be at least 7d
Diffstat (limited to 'src/swarm/members.rs')
-rw-r--r--src/swarm/members.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/swarm/members.rs b/src/swarm/members.rs
index 6be523c..098c767 100644
--- a/src/swarm/members.rs
+++ b/src/swarm/members.rs
@@ -229,9 +229,16 @@ pub(crate) fn electorate(doc: &impl ReadDoc, now_ms: u64, window: Duration) -> V
/// drops out of the electorate (a seventh of the window), but at most hourly and at
/// least daily, so idle swarms stay quiet.
fn alive_renewal(window: Duration) -> Duration {
- (window / 7).clamp(Duration::from_secs(3600), Duration::from_secs(24 * 3600))
+ (window / 7).clamp(RENEWAL_MOST_OFTEN, Duration::from_secs(24 * 3600))
}
+const RENEWAL_MOST_OFTEN: Duration = Duration::from_secs(3600);
+
+/// The shortest `--electorate-window`: seven renewals at most often, so a live node
+/// renews within a seventh of it, as with any longer one.
+pub(crate) const MIN_ELECTORATE_WINDOW: Duration =
+ Duration::from_secs(7 * RENEWAL_MOST_OFTEN.as_secs());
+
/// Registers this node if it is ready and its entry is missing, keeps its alias as
/// configured (set, changed or removed after a restart with another `--alias`) and its
/// addresses as the transport gives them, and renews its `alive` stamp now and then