pub struct ConsensusEngine { /* private fields */ }Expand description
Native consensus engine for AI-Chain
Implementations§
Source§impl ConsensusEngine
impl ConsensusEngine
Sourcepub fn new(config: ConsensusConfig) -> Result<Self, ConsensusError>
pub fn new(config: ConsensusConfig) -> Result<Self, ConsensusError>
Create new consensus engine
Sourcepub fn with_rpc(config: ConsensusConfig, endpoint: String) -> Self
pub fn with_rpc(config: ConsensusConfig, endpoint: String) -> Self
Create engine with specific RPC endpoint
Sourcepub async fn start(&mut self) -> Result<(), ConsensusError>
pub async fn start(&mut self) -> Result<(), ConsensusError>
Start the consensus engine
Sourcepub async fn stop(&mut self) -> Result<(), ConsensusError>
pub async fn stop(&mut self) -> Result<(), ConsensusError>
Stop the consensus engine
Sourcepub async fn submit_block(
&mut self,
block: AIChainBlock,
) -> Result<(), ConsensusError>
pub async fn submit_block( &mut self, block: AIChainBlock, ) -> Result<(), ConsensusError>
Submit a block for consensus
Sourcepub async fn record_vote(
&mut self,
vote: AIChainVote,
) -> Result<bool, ConsensusError>
pub async fn record_vote( &mut self, vote: AIChainVote, ) -> Result<bool, ConsensusError>
Record a vote
Sourcepub async fn is_accepted(&self, block_id: &[u8; 32]) -> bool
pub async fn is_accepted(&self, block_id: &[u8; 32]) -> bool
Check if a block is accepted (finalized)
Sourcepub async fn get_height(&self) -> u64
pub async fn get_height(&self) -> u64
Get current block height
Sourcepub fn mode(&self) -> &ConsensusMode
pub fn mode(&self) -> &ConsensusMode
Get consensus mode
Sourcepub fn config(&self) -> &ConsensusConfig
pub fn config(&self) -> &ConsensusConfig
Get configuration
Sourcepub fn is_quantum_safe(&self) -> bool
pub fn is_quantum_safe(&self) -> bool
Check if quantum-safe mode is enabled
Auto Trait Implementations§
impl Freeze for ConsensusEngine
impl !RefUnwindSafe for ConsensusEngine
impl Send for ConsensusEngine
impl Sync for ConsensusEngine
impl Unpin for ConsensusEngine
impl UnsafeUnpin for ConsensusEngine
impl !UnwindSafe for ConsensusEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more