aboutsummaryrefslogtreecommitdiffstats
path: root/src/federation/store/set.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/federation/store/set.rs')
-rw-r--r--src/federation/store/set.rs15
1 files changed, 15 insertions, 0 deletions
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<F: Fold> Set<F> {
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<Duration> {
+ 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]> {