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: StringOur 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: VersionVectorOur current version vector.
local_heads: Vec<Hash>Our current DAG heads.
stable_frontier: VersionVectorThe computed stable frontier (min of all known frontiers).
config: StabilityConfigConfiguration.
Implementations§
Source§impl StabilityMonitor
impl StabilityMonitor
Sourcepub fn with_config(
replica_id: impl Into<String>,
config: StabilityConfig,
) -> Self
pub fn with_config( replica_id: impl Into<String>, config: StabilityConfig, ) -> Self
Create with custom configuration.
Sourcepub fn replica_id(&self) -> &str
pub fn replica_id(&self) -> &str
Get our replica ID.
Sourcepub fn update_local_frontier(&mut self, vv: VersionVector, heads: Vec<Hash>)
pub fn update_local_frontier(&mut self, vv: VersionVector, heads: Vec<Hash>)
Update our local frontier.
Sourcepub fn update_peer_frontier(&mut self, update: FrontierUpdate)
pub fn update_peer_frontier(&mut self, update: FrontierUpdate)
Update a peer’s frontier.
Sourcepub fn remove_peer(&mut self, peer_id: &str)
pub fn remove_peer(&mut self, peer_id: &str)
Remove a peer from tracking.
Sourcepub fn tracked_peers(&self) -> Vec<&String>
pub fn tracked_peers(&self) -> Vec<&String>
Get the list of tracked peers.
Sourcepub fn peer_count(&self) -> usize
pub fn peer_count(&self) -> usize
Get the number of tracked peers.
Sourcepub fn peer_frontier(&self, peer_id: &str) -> Option<&VersionVector>
pub fn peer_frontier(&self, peer_id: &str) -> Option<&VersionVector>
Get a peer’s frontier.
Sourcepub fn stable_frontier(&self) -> &VersionVector
pub fn stable_frontier(&self) -> &VersionVector
Get the stable frontier.
Sourcepub fn local_frontier(&self) -> &VersionVector
pub fn local_frontier(&self) -> &VersionVector
Get the local frontier.
Sourcepub fn is_operation_stable(&self, replica_id: &str, sequence: u64) -> bool
pub fn is_operation_stable(&self, replica_id: &str, sequence: u64) -> bool
Check if a specific operation is stable.
Sourcepub fn is_stable(&self, vv: &VersionVector) -> bool
pub fn is_stable(&self, vv: &VersionVector) -> bool
Check if a version vector is fully stable.
Sourcepub fn stability_state(&self, vv: &VersionVector) -> StabilityState
pub fn stability_state(&self, vv: &VersionVector) -> StabilityState
Get the stability state for a version vector.
Sourcepub fn has_quorum(&self) -> bool
pub fn has_quorum(&self) -> bool
Check if we have enough peers for meaningful stability.
Sourcepub fn stale_peers(&self, current_time: u64) -> Vec<String>
pub fn stale_peers(&self, current_time: u64) -> Vec<String>
Get stale peers (those with old frontier updates).
Sourcepub fn gc_stale_peers(&mut self, current_time: u64)
pub fn gc_stale_peers(&mut self, current_time: u64)
Remove stale peers.
Sourcefn recompute_stable_frontier(&mut self)
fn recompute_stable_frontier(&mut self)
Recompute the stable frontier.
Sourcepub fn stats(&self) -> StabilityStats
pub fn stats(&self) -> StabilityStats
Get statistics about stability.
Sourcepub fn create_frontier_update(&self, timestamp: u64) -> FrontierUpdate
pub fn create_frontier_update(&self, timestamp: u64) -> FrontierUpdate
Create a frontier update message for broadcasting.