Skip to main content

ChainSyncStatus

Struct ChainSyncStatus 

Source
pub struct ChainSyncStatus {
    pub chains: HashMap<String, u64>,
    /* private fields */
}
Expand description

Cross-chain synchronization tracker.

Stores the current head block for each chain so callers can ask questions like “have all chains passed block N?” or “are all chains within K blocks of their respective tips?”

Fields§

§chains: HashMap<String, u64>

Maps chain id → latest known head block.

Implementations§

Source§

impl ChainSyncStatus

Source

pub fn new() -> Self

Create an empty sync status tracker.

Source

pub fn update(&mut self, chain: &str, head: u64)

Update the head block for a chain.

Source

pub fn update_with_timestamp(&mut self, chain: &str, head: u64, timestamp: i64)

Update both the head block and its timestamp for a chain.

Source

pub fn update_tip(&mut self, chain: &str, tip: u64)

Update the known chain tip (latest block on the network) for a chain.

Source

pub fn min_timestamp(&self) -> Option<i64>

Returns the earliest (minimum) timestamp across all chains with a recorded timestamp. Returns None if no timestamps are recorded.

Source

pub fn max_timestamp(&self) -> Option<i64>

Returns the latest (maximum) timestamp across all chains.

Source

pub fn all_past_block(&self, _chain: &str, block: u64) -> bool

Returns true if every registered chain has processed past block.

Returns false if there are no chains registered.

Source

pub fn all_caught_up(&self, threshold_blocks: u64) -> bool

Returns true if all chains are within threshold_blocks of their recorded tips.

Returns false when no chains have tip information recorded.

Source

pub fn head_of(&self, chain: &str) -> Option<u64>

Returns the head block for a specific chain.

Source

pub fn lag_of(&self, chain: &str) -> Option<u64>

Returns the lag (tip - head) for a specific chain. None if the chain or its tip is not recorded.

Source

pub fn len(&self) -> usize

Returns the number of chains being tracked.

Source

pub fn is_empty(&self) -> bool

Returns true when no chains are tracked.

Source

pub async fn from_coordinator(coordinator: &Arc<MultiChainCoordinator>) -> Self

Build a ChainSyncStatus snapshot from a MultiChainCoordinator.

Trait Implementations§

Source§

impl Clone for ChainSyncStatus

Source§

fn clone(&self) -> ChainSyncStatus

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChainSyncStatus

Source§

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

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

impl Default for ChainSyncStatus

Source§

fn default() -> ChainSyncStatus

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

impl<'de> Deserialize<'de> for ChainSyncStatus

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ChainSyncStatus

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,