From 79396943ec9eee8ffd64669baaa3484fcad33feb Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 1 Dec 2026 04:54:24 +0000 Subject: federation: the store's worker looks when something changed, not every five seconds Every five seconds it looked at the changes screening refused, wrote its set of events to its file, and read its store anew. It now looks where screening refuses a change, writes the set five seconds after it changed, and wakes for what the set is to let go of. A node voting by itself still looks every five seconds: its rules count time. --- src/federation/store/set.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/federation/store') diff --git a/src/federation/store/set.rs b/src/federation/store/set.rs index 8c2be6d..a31d9bd 100644 --- a/src/federation/store/set.rs +++ b/src/federation/store/set.rs @@ -485,6 +485,21 @@ impl Set { self.beside.len() != before } + /// How long, at `now`, until the document lets go of something a checkpoint forgot + /// (`expire`), if it keeps any. + pub(crate) fn next_expiry(&self, now: Instant) -> Option { + self.beside + .values() + .filter_map(|(_, why)| match why { + Beside::Forgotten(since) => Some( + (*since + self.keeps_forgotten).saturating_duration_since(now) + + Duration::from_millis(1), + ), + _ => None, + }) + .min() + } + /// The bytes of an event the document gives to others: one its store holds, one /// held beside it, or one the store holds back. pub(crate) fn get(&self, id: &Id) -> Option<&[u8]> { -- cgit v1.3.1