ConsensusManager

Trait ConsensusManager 

Source
pub trait ConsensusManager<T>: Send + Sync {
    // Required methods
    async fn initialize(&mut self) -> Result<()>;
    async fn propose(
        &mut self,
        proposal: ConsensusProposal<T>,
    ) -> Result<String>;
    async fn vote(
        &mut self,
        proposal_id: &str,
        vote: ConsensusVote,
    ) -> Result<()>;
    async fn get_decision(
        &self,
        proposal_id: &str,
    ) -> Result<Option<ConsensusDecision<T>>>;
    async fn handle_node_failure(&mut self, node_id: &str) -> Result<()>;
    async fn handle_node_recovery(&mut self, node_id: &str) -> Result<()>;
    async fn get_state(&self) -> Result<ConsensusSystemState>;
    async fn get_health_score(&self) -> Result<f64>;
    async fn shutdown(&mut self) -> Result<()>;
}
Expand description

Consensus manager trait for different algorithms

Required Methods§

Source

async fn initialize(&mut self) -> Result<()>

Initialize consensus manager

Source

async fn propose(&mut self, proposal: ConsensusProposal<T>) -> Result<String>

Propose a value for consensus

Source

async fn vote(&mut self, proposal_id: &str, vote: ConsensusVote) -> Result<()>

Vote on a proposal

Source

async fn get_decision( &self, proposal_id: &str, ) -> Result<Option<ConsensusDecision<T>>>

Get consensus decision if available

Source

async fn handle_node_failure(&mut self, node_id: &str) -> Result<()>

Handle node failure

Source

async fn handle_node_recovery(&mut self, node_id: &str) -> Result<()>

Handle node recovery

Source

async fn get_state(&self) -> Result<ConsensusSystemState>

Get current consensus state

Source

async fn get_health_score(&self) -> Result<f64>

Get health score

Source

async fn shutdown(&mut self) -> Result<()>

Shutdown consensus manager

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§