StabilityMonitor

Struct StabilityMonitor 

Source
pub struct StabilityMonitor {
    replica_id: String,
    peer_frontiers: HashMap<String, VersionVector>,
    peer_heads: HashMap<String, Vec<Hash>>,
    last_update: HashMap<String, u64>,
    local_frontier: VersionVector,
    local_heads: Vec<Hash>,
    stable_frontier: VersionVector,
    config: StabilityConfig,
}
Expand description

Monitors stability across replicas for safe compaction decisions.

Stability is achieved when an update has been delivered to all tracked peers. Only stable updates can be safely compacted.

Fields§

§replica_id: String

Our replica ID.

§peer_frontiers: HashMap<String, VersionVector>

Known peer frontiers (version vectors).

§peer_heads: HashMap<String, Vec<Hash>>

Known peer heads (DAG heads).

§last_update: HashMap<String, u64>

Timestamp of last update from each peer.

§local_frontier: VersionVector

Our current version vector.

§local_heads: Vec<Hash>

Our current DAG heads.

§stable_frontier: VersionVector

The computed stable frontier (min of all known frontiers).

§config: StabilityConfig

Configuration.

Implementations§

Source§

impl StabilityMonitor

Source

pub fn new(replica_id: impl Into<String>) -> Self

Create a new stability monitor.

Source

pub fn with_config( replica_id: impl Into<String>, config: StabilityConfig, ) -> Self

Create with custom configuration.

Source

pub fn replica_id(&self) -> &str

Get our replica ID.

Source

pub fn update_local_frontier(&mut self, vv: VersionVector, heads: Vec<Hash>)

Update our local frontier.

Source

pub fn update_peer_frontier(&mut self, update: FrontierUpdate)

Update a peer’s frontier.

Source

pub fn remove_peer(&mut self, peer_id: &str)

Remove a peer from tracking.

Source

pub fn tracked_peers(&self) -> Vec<&String>

Get the list of tracked peers.

Source

pub fn peer_count(&self) -> usize

Get the number of tracked peers.

Source

pub fn peer_frontier(&self, peer_id: &str) -> Option<&VersionVector>

Get a peer’s frontier.

Source

pub fn stable_frontier(&self) -> &VersionVector

Get the stable frontier.

Source

pub fn local_frontier(&self) -> &VersionVector

Get the local frontier.

Source

pub fn is_operation_stable(&self, replica_id: &str, sequence: u64) -> bool

Check if a specific operation is stable.

Source

pub fn is_stable(&self, vv: &VersionVector) -> bool

Check if a version vector is fully stable.

Source

pub fn stability_state(&self, vv: &VersionVector) -> StabilityState

Get the stability state for a version vector.

Source

pub fn has_quorum(&self) -> bool

Check if we have enough peers for meaningful stability.

Source

pub fn stale_peers(&self, current_time: u64) -> Vec<String>

Get stale peers (those with old frontier updates).

Source

pub fn gc_stale_peers(&mut self, current_time: u64)

Remove stale peers.

Source

fn recompute_stable_frontier(&mut self)

Recompute the stable frontier.

Source

pub fn stats(&self) -> StabilityStats

Get statistics about stability.

Source

pub fn create_frontier_update(&self, timestamp: u64) -> FrontierUpdate

Create a frontier update message for broadcasting.

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.