From f0ddd8e52c0765bf5b3743fbc060e5dc619820f3 Mon Sep 17 00:00:00 2001 From: Matthew Scheffel Date: Tue, 16 Jul 2024 22:09:16 -0300 Subject: [PATCH] allow negative age --- src/core/pdu/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/pdu/mod.rs b/src/core/pdu/mod.rs index a4254b08..7cc649c8 100644 --- a/src/core/pdu/mod.rs +++ b/src/core/pdu/mod.rs @@ -116,9 +116,10 @@ impl PduEvent { .map_or_else(|| Ok(BTreeMap::new()), |u| serde_json::from_str(u.get())) .map_err(|_| Error::bad_database("Invalid unsigned in pdu event"))?; - let now: u64 = MilliSecondsSinceUnixEpoch::now().get().into(); - let then: u64 = self.origin_server_ts.into(); - let this_age: u64 = now - then; + // deliberately allowing for the possibility of negative age + let now: i128 = MilliSecondsSinceUnixEpoch::now().get().into(); + let then: i128 = self.origin_server_ts.into(); + let this_age: i128 = now - then; unsigned.insert("age".to_owned(), to_raw_value(&this_age).unwrap()); self.unsigned = Some(to_raw_value(&unsigned).expect("unsigned is valid"));