use CLOCK_MONOTONIC_RAW instead of CLOCK_BOOTTIME

This commit is contained in:
Hailey Somerville 2023-12-29 21:26:37 +11:00
parent 5ea6a9ef6c
commit 0a555d4883

View file

@ -4,8 +4,8 @@ use nix::time::ClockId;
use bark_protocol::types::TimestampMicros;
pub fn now() -> TimestampMicros {
let timespec = nix::time::clock_gettime(ClockId::CLOCK_BOOTTIME)
.expect("clock_gettime(CLOCK_BOOTTIME) failed, are we on Linux?");
let timespec = nix::time::clock_gettime(ClockId::CLOCK_MONOTONIC_RAW)
.expect("clock_gettime(CLOCK_MONOTONIC_RAW) failed, are we on Linux?");
let micros = u64::try_from(timespec.num_microseconds())
.expect("cannot convert i64 time value to u64");