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§
Sourceasync fn initialize(&mut self) -> Result<()>
async fn initialize(&mut self) -> Result<()>
Initialize consensus manager
Sourceasync fn propose(&mut self, proposal: ConsensusProposal<T>) -> Result<String>
async fn propose(&mut self, proposal: ConsensusProposal<T>) -> Result<String>
Propose a value for consensus
Sourceasync fn vote(&mut self, proposal_id: &str, vote: ConsensusVote) -> Result<()>
async fn vote(&mut self, proposal_id: &str, vote: ConsensusVote) -> Result<()>
Vote on a proposal
Sourceasync fn get_decision(
&self,
proposal_id: &str,
) -> Result<Option<ConsensusDecision<T>>>
async fn get_decision( &self, proposal_id: &str, ) -> Result<Option<ConsensusDecision<T>>>
Get consensus decision if available
Sourceasync fn handle_node_failure(&mut self, node_id: &str) -> Result<()>
async fn handle_node_failure(&mut self, node_id: &str) -> Result<()>
Handle node failure
Sourceasync fn handle_node_recovery(&mut self, node_id: &str) -> Result<()>
async fn handle_node_recovery(&mut self, node_id: &str) -> Result<()>
Handle node recovery
Sourceasync fn get_state(&self) -> Result<ConsensusSystemState>
async fn get_state(&self) -> Result<ConsensusSystemState>
Get current consensus state
Sourceasync fn get_health_score(&self) -> Result<f64>
async fn get_health_score(&self) -> Result<f64>
Get health score
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.