nodedb 0.3.0-beta.1

Local-first, real-time, edge-to-cloud hybrid database for multi-modal workloads
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// SPDX-License-Identifier: BUSL-1.1

//! Wall-clock helper shared by every lease code path that needs a
//! "real time now" reference — the renewal loop, the drain tracker
//! check, and the drain TTL computation. See `lease::renewal::tick`
//! for the rationale on why these paths use wall clock directly
//! instead of `HlcClock::peek`.

/// Wall-clock nanoseconds since Unix epoch.
pub(crate) fn wall_now_ns() -> u64 {
    std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .map(|d| d.as_nanos() as u64)
        .unwrap_or(0)
}