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
impl ChainSyncStatus
Sourcepub fn update_with_timestamp(&mut self, chain: &str, head: u64, timestamp: i64)
pub fn update_with_timestamp(&mut self, chain: &str, head: u64, timestamp: i64)
Update both the head block and its timestamp for a chain.
Sourcepub fn update_tip(&mut self, chain: &str, tip: u64)
pub fn update_tip(&mut self, chain: &str, tip: u64)
Update the known chain tip (latest block on the network) for a chain.
Sourcepub fn min_timestamp(&self) -> Option<i64>
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.
Sourcepub fn max_timestamp(&self) -> Option<i64>
pub fn max_timestamp(&self) -> Option<i64>
Returns the latest (maximum) timestamp across all chains.
Sourcepub fn all_past_block(&self, _chain: &str, block: u64) -> bool
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.
Sourcepub fn all_caught_up(&self, threshold_blocks: u64) -> bool
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.
Sourcepub fn lag_of(&self, chain: &str) -> Option<u64>
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.
Sourcepub async fn from_coordinator(coordinator: &Arc<MultiChainCoordinator>) -> Self
pub async fn from_coordinator(coordinator: &Arc<MultiChainCoordinator>) -> Self
Build a ChainSyncStatus snapshot from a MultiChainCoordinator.
Trait Implementations§
Source§impl Clone for ChainSyncStatus
impl Clone for ChainSyncStatus
Source§fn clone(&self) -> ChainSyncStatus
fn clone(&self) -> ChainSyncStatus
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more