Skip to main content

Module time

Module time 

Source
Expand description

§Wire-format time and duration types

Two newtypes that replace raw i64 / Duration throughout the protocol:

  • TimeMillis — an instant as milliseconds since the Unix epoch. Used on every signed message (post timestamps, peer announcements, PoW birth certificates) so that clock drift can be bounded by POW_MAX_CLOCK_DRIFT_MILLIS.
  • DurationMillis — a span of milliseconds. Used for bucket durations, cache TTLs, retry windows. Supports const_mul so the constants in crate::tools::config can be composed at compile time.

Both types round-trip through a fixed 8-byte big-endian wire encoding (TimeMillisBytes and DurationMillisBytes) so they hash and sign the same way on every platform. Human-readable parsing / formatting uses a YYYYMMDD.hhmmss.SSS format for times and <N><unit> for durations (e.g. 1D, 15m, 250M for milliseconds).

The canonical unit constants — MILLIS_IN_MILLISECOND, MILLIS_IN_SECOND, …, MILLIS_IN_YEAR — are const DurationMillis so they can be used in const contexts (e.g. pub const X: DurationMillis = MILLIS_IN_MINUTE.const_mul(5);).

Structs§

DurationMillis
DurationMillisBytes
TimeMillis
TimeMillisBytes

Constants§

DURATION_MILLIS_BYTES
MILLIS_IN_DAY
MILLIS_IN_HOUR
MILLIS_IN_MILLISECOND
MILLIS_IN_MINUTE
MILLIS_IN_MONTH
MILLIS_IN_SECOND
MILLIS_IN_WEEK
MILLIS_IN_YEAR
TIME_MILLIS_BYTES

Functions§

to_bucket