diff --git a/pubky-common/src/timestamp.rs b/pubky-common/src/timestamp.rs index c3c9846..4317484 100644 --- a/pubky-common/src/timestamp.rs +++ b/pubky-common/src/timestamp.rs @@ -1,4 +1,4 @@ -//! Strictly monotonic unix timestamp in microseconds +//! Absolutely monotonic unix timestamp in microseconds use serde::{Deserialize, Serialize}; use std::fmt::Display; @@ -31,7 +31,7 @@ impl TimestampFactory { } pub fn now(&mut self) -> Timestamp { - // Ensure strict monotonicity. + // Ensure absolute monotonicity. self.last_time = (system_time() & TIME_MASK).max(self.last_time + CLOCK_MASK + 1); // Add clock_id to the end of the timestamp @@ -48,13 +48,13 @@ impl Default for TimestampFactory { static DEFAULT_FACTORY: Lazy> = Lazy::new(|| Mutex::new(TimestampFactory::default())); -/// STrictly monotonic timestamp since [SystemTime::UNIX_EPOCH] in microseconds as u64. +/// Absolutely monotonic timestamp since [SystemTime::UNIX_EPOCH] in microseconds as u64. /// /// The purpose of this timestamp is to unique per "user", not globally, /// it achieves this by: /// 1. Override the last byte with a random `clock_id`, reducing the probability /// of two matching timestamps across multiple machines/threads. -/// 2. Gurantee that the remaining 3 bytes are ever increasing (strictly monotonic) within +/// 2. Gurantee that the remaining 3 bytes are ever increasing (absolutely monotonic) within /// the same thread regardless of the wall clock value /// /// This timestamp is also serialized as BE bytes to remain sortable. @@ -215,7 +215,7 @@ mod tests { use super::*; #[test] - fn strictly_monotonic() { + fn absolutely_monotonic() { const COUNT: usize = 100; let mut set = HashSet::with_capacity(COUNT);