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 byPOW_MAX_CLOCK_DRIFT_MILLIS.DurationMillis— a span of milliseconds. Used for bucket durations, cache TTLs, retry windows. Supportsconst_mulso the constants incrate::tools::configcan 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§
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