pub struct ConsensusEngine { /* private fields */ }Expand description
The consensus engine.
Implementations§
Source§impl ConsensusEngine
impl ConsensusEngine
Sourcepub fn new(
config: EngineConfig,
validator_key: Option<PrivateKey>,
validators: ValidatorSet,
mempool: Arc<Mempool>,
) -> Self
pub fn new( config: EngineConfig, validator_key: Option<PrivateKey>, validators: ValidatorSet, mempool: Arc<Mempool>, ) -> Self
Creates a new consensus engine.
Sourcepub fn transaction_sender(&self) -> Sender<Transaction>
pub fn transaction_sender(&self) -> Sender<Transaction>
Returns a handle for submitting transactions.
Sourcepub fn subscribe(&self) -> Receiver<ConsensusEvent>
pub fn subscribe(&self) -> Receiver<ConsensusEvent>
Subscribes to consensus events.
Sourcepub fn state(&self) -> EngineState
pub fn state(&self) -> EngineState
Returns the current engine state.
Sourcepub fn finalized_height(&self) -> u64
pub fn finalized_height(&self) -> u64
Returns the latest finalized height.
Sourcepub fn current_leader(&self) -> Option<SerializablePublicKey>
pub fn current_leader(&self) -> Option<SerializablePublicKey>
Gets the current leader.
Sourcepub async fn submit_transaction(&self, tx: Transaction) -> Result<TransactionId>
pub async fn submit_transaction(&self, tx: Transaction) -> Result<TransactionId>
Submits a transaction to the mempool.
Sourcepub fn get_block(&self, height: u64) -> Option<FinalizedBlock>
pub fn get_block(&self, height: u64) -> Option<FinalizedBlock>
Gets a finalized block by height.
Sourcepub fn validators(&self) -> Arc<RwLock<ValidatorSet>> ⓘ
pub fn validators(&self) -> Arc<RwLock<ValidatorSet>> ⓘ
Gets the validator set.
Sourcepub async fn run<A: ConsensusApplication>(&self, app: Arc<A>) -> Result<()>
pub async fn run<A: ConsensusApplication>(&self, app: Arc<A>) -> Result<()>
Runs the consensus engine.
This is the main event loop that drives consensus.
Sourcepub fn advance_view(&self)
pub fn advance_view(&self)
Advances to the next view.
Auto Trait Implementations§
impl Freeze for ConsensusEngine
impl !RefUnwindSafe for ConsensusEngine
impl Send for ConsensusEngine
impl Sync for ConsensusEngine
impl Unpin 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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more