Skip to main content

HybridClock

Struct HybridClock 

Source
pub struct HybridClock { /* private fields */ }
Expand description

A Hybrid Logical Clock instance.

Each node in the EXOCHAIN network maintains its own HybridClock. The clock is driven by a deterministic physical source and a logical counter. The default constructor does not read host time; runtime adapters that need deployment-specific physical metadata must inject an explicit HLC source.

Implementations§

Source§

impl HybridClock

Source

pub fn new() -> Self

Create a new clock driven by EXOCHAIN’s deterministic default source.

Source

pub fn with_wall_clock( physical_source: impl Fn() -> u64 + Send + 'static, ) -> Self

Create a clock with a custom physical source.

Source

pub fn with_wall_clock_and_max_drift( physical_source: impl Fn() -> u64 + Send + 'static, max_drift_ms: u64, ) -> Self

Create a clock with a custom physical source and drift tolerance.

Source

pub fn with_fallible_wall_clock( physical_source: impl Fn() -> Result<u64> + Send + 'static, ) -> Self

Create a clock with a fallible physical source.

Source

pub fn with_fallible_wall_clock_and_max_drift( physical_source: impl Fn() -> Result<u64> + Send + 'static, max_drift_ms: u64, ) -> Self

Create a clock with a fallible physical source and drift tolerance.

Source

pub fn max_drift_ms(&self) -> u64

Return this clock’s configured maximum forward drift in milliseconds.

Source

pub fn now(&mut self) -> Result<Timestamp>

Generate the next timestamp.

Guarantees: the returned timestamp is strictly greater than any previously returned by this clock.

Source

pub fn update(&mut self, remote: &Timestamp) -> Result<Timestamp>

Merge a remote timestamp and advance the local clock.

The returned timestamp is guaranteed to be greater than both the local state and the remote timestamp.

§Errors

Returns ExoError::ClockDrift if the remote timestamp is unreasonably far ahead of the local physical source.

Source

pub fn is_before(a: &Timestamp, b: &Timestamp) -> bool

Causal ordering check: returns true if a happened-before b.

Source

pub fn current(&self) -> Timestamp

Return the current state as a Timestamp without advancing.

Trait Implementations§

Source§

impl Debug for HybridClock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HybridClock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V