From 32cb8adf6ffd47bdf5c458607a1eed01ff12ed93 Mon Sep 17 00:00:00 2001 From: nazeh Date: Tue, 17 Sep 2024 14:41:32 +0300 Subject: [PATCH] chore: change 'monotonic' to 'strict monotonic' in code comements --- pubky-common/src/timestamp.rs | 10 +++++----- pubky/pkg/README.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pubky-common/src/timestamp.rs b/pubky-common/src/timestamp.rs index 848f894..c3c9846 100644 --- a/pubky-common/src/timestamp.rs +++ b/pubky-common/src/timestamp.rs @@ -1,4 +1,4 @@ -//! Monotonic unix timestamp in microseconds +//! Strictly 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 monotonicity. + // Ensure strict 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())); -/// Monotonic timestamp since [SystemTime::UNIX_EPOCH] in microseconds as u64. +/// STrictly 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 (monotonic) within +/// 2. Gurantee that the remaining 3 bytes are ever increasing (strictly 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 monotonic() { + fn strictly_monotonic() { const COUNT: usize = 100; let mut set = HashSet::with_capacity(COUNT); diff --git a/pubky/pkg/README.md b/pubky/pkg/README.md index 2228266..18dce88 100644 --- a/pubky/pkg/README.md +++ b/pubky/pkg/README.md @@ -139,7 +139,7 @@ let response = await client.put(url, body); let response = await client.get(url) ``` - url: A string representing the Pubky URL. -- Returns: A response object containing the requested data. +- Returns: A Uint8Array object containing the requested data, or `undefined` if `NOT_FOUND`. ### delete