From b6743899468db6304173aca4c7b32d05ea8d92c9 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 03:23:21 +0000 Subject: remake: the switch worker looks when something changed, not every second It read the remake records and its peers' epochs once a second, whatever happened. It now looks when the records change, within a second of a peer saying another epoch than this node's, and when a vote is due; and by itself, once a second, only while something waits on time: a remake of this epoch open or committed, a rejoin, a catch-up, a member on another epoch. What it keeps for a time, an archived document or a remake's content, it wakes for when that is due. --- src/remake/records.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/remake/records.rs') diff --git a/src/remake/records.rs b/src/remake/records.rs index 22aaee3..9b0c8f1 100644 --- a/src/remake/records.rs +++ b/src/remake/records.rs @@ -75,6 +75,13 @@ impl Retention { self.epochs.is_some_and(|limit| epochs <= limit) || self.age_ms.is_some_and(|limit| age_ms <= limit) } + + /// How long until its age limit passes, `age_ms` after the fact, where that is + /// ahead: none where it has none, or it passed, and the count of epochs decides. + pub(crate) fn age_left(&self, age_ms: u64) -> Option { + let left = self.age_ms?.checked_sub(age_ms)?; + Some(std::time::Duration::from_millis(left)) + } } #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] -- cgit v1.3.1