shardline-protocol 1.0.0

Protocol-facing hashes, ranges, secrets, and token types for Shardline.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::time::{Duration, SystemTime, UNIX_EPOCH};

/// Returns the current Unix timestamp in seconds.
///
/// If the system clock reports a time before the Unix epoch, this returns `0`.
#[must_use]
pub fn unix_now_seconds_lossy() -> u64 {
    SystemTime::now()
        .duration_since(UNIX_EPOCH)
        .unwrap_or(Duration::ZERO)
        .as_secs()
}