pub struct SyncClock {
pub hlc: Hlc,
pub knowledge: BTreeMap<u64, EstimateInterval>,
}Expand description
A light-cone-aware CRDT clock: a Hybrid Logical Clock (causal order) plus per-node knowledge
intervals (light-cone-bounded estimates of each peer’s current time). Its merge is a join over
a lattice — max on the HLC, interval intersection per node — so replicas separated by bounded
(even interplanetary) delay converge conflict-free, regardless of message order. This realises
“spacelike separation = CRDT concurrency”: events with no shared light cone need no total order,
only this commutative/associative/idempotent merge.
Fields§
§hlc: Hlc§knowledge: BTreeMap<u64, EstimateInterval>Implementations§
Source§impl SyncClock
impl SyncClock
pub fn new() -> Self
Sourcepub fn tick(&self, now_nanos: i64) -> SyncClock
pub fn tick(&self, now_nanos: i64) -> SyncClock
Stamp a local event (advance the HLC); knowledge is carried unchanged.
Sourcepub fn observe(&self, node: u64, interval: EstimateInterval) -> SyncClock
pub fn observe(&self, node: u64, interval: EstimateInterval) -> SyncClock
Record (and tighten) what this clock knows about node node’s current time. A fresh node is
inserted; a known node’s interval is intersected, so observation can only narrow knowledge.
Sourcepub fn merge(&self, other: &SyncClock) -> SyncClock
pub fn merge(&self, other: &SyncClock) -> SyncClock
The CRDT join with another replica — max HLC (the lattice join on the derived total order),
per-node interval intersection on shared keys, union of distinct keys. Commutative,
associative, and idempotent, so gossip converges regardless of message order.