referrerpolicy=no-referrer-when-downgrade

Crate polkadot_node_clock

Crate polkadot_node_clock 

Source
Expand description

Clock abstraction shared by Polkadot node subsystems.

Production code uses SystemClock. Tests inject a deterministic mock so subsystems’ time-dependent behavior can be driven and observed without wall-clock dependence.

Subsystems that need time should accept Arc<dyn Clock> rather than reading Instant::now(), SystemTime::now(), futures_timer::Delay::new(..), or tokio::time::sleep(..) directly. Consider enforcing this via a crate-level clippy.toml (see polkadot-collator-protocol for an example).

Note: not every subsystem currently routes all of its time reads through this trait. In particular, polkadot-node-core-chain-selection, polkadot-node-core-av-store, and polkadot-node-core-dispute-coordinator presently use this trait only for their wall-clock reads and continue to call futures_timer::Delay::new directly for their internal timers. Those call sites need to be migrated before those subsystems can run under a deterministic test harness.

Re-exports§

pub use mock::MockClock;

Modules§

mock
Deterministic Clock implementation for tests.

Structs§

SystemClock
Production clock backed by std::time and futures_timer.

Traits§

Clock
Abstraction over wall-clock time. See module-level docs.

Functions§

system_clock
Convenience constructor returning a thread-safe handle to a SystemClock.

Type Aliases§

BoxedDelay
Boxed future returned by Clock::delay.