Calculate Age Rather than Hardcoding to 1 (#531)
This commit is contained in:
parent
c29197b3f4
commit
06531993f6
1 changed files with 6 additions and 1 deletions
|
@ -116,7 +116,12 @@ 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"))?;
|
||||
|
||||
unsigned.insert("age".to_owned(), to_raw_value(&1).unwrap());
|
||||
// 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.saturating_sub(then);
|
||||
|
||||
unsigned.insert("age".to_owned(), to_raw_value(&this_age).unwrap());
|
||||
self.unsigned = Some(to_raw_value(&unsigned).expect("unsigned is valid"));
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Reference in a new issue