From 43b5280a71d5095b0763b10844ca99b4c8049107 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 1 Nov 2026 13:25:49 +0100 Subject: electorate window must be at least 7d --- src/swarm/members.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/swarm') 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 -- cgit v1.3.1