[−][src]Trait abci::Consensus
Trait for managing consensus of blockchain.
Details
Consensus should maintain a consensus_state
- the working state for block execution. It should be updated by
the calls to begin_block
, deliver_tx
, and end_block
during block execution and committed to disk as the
latest committed state during commit
.
Updates made to the consensus_state
by each method call must be readable by each subsequent method - ie. the
updates are linearizable.
Required methods
fn init_chain<'life0, 'async_trait>(
&'life0 self,
init_chain_request: InitChainRequest
) -> Pin<Box<dyn Future<Output = InitChainResponse> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
&'life0 self,
init_chain_request: InitChainRequest
) -> Pin<Box<dyn Future<Output = InitChainResponse> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Called once upon genesis. Usually used to establish initial (genesis) state.
fn begin_block<'life0, 'async_trait>(
&'life0 self,
begin_block_request: BeginBlockRequest
) -> Pin<Box<dyn Future<Output = BeginBlockResponse> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
&'life0 self,
begin_block_request: BeginBlockRequest
) -> Pin<Box<dyn Future<Output = BeginBlockResponse> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Signals the beginning of a new block. Called prior to any deliver_tx
s.
fn deliver_tx<'life0, 'async_trait>(
&'life0 self,
deliver_tx_request: DeliverTxRequest
) -> Pin<Box<dyn Future<Output = Result<DeliverTxResponse>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
&'life0 self,
deliver_tx_request: DeliverTxRequest
) -> Pin<Box<dyn Future<Output = Result<DeliverTxResponse>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Execute the transaction in full. The workhorse of the application.
fn end_block<'life0, 'async_trait>(
&'life0 self,
end_block_request: EndBlockRequest
) -> Pin<Box<dyn Future<Output = EndBlockResponse> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
&'life0 self,
end_block_request: EndBlockRequest
) -> Pin<Box<dyn Future<Output = EndBlockResponse> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Signals the end of a block. Called after all transactions, prior to each commit
.
fn commit<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = CommitResponse> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
&'life0 self
) -> Pin<Box<dyn Future<Output = CommitResponse> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Persist the application state.
Details
Application state should only be persisted to disk during commit
.
Before commit
is called, Tendermint locks and flushes the mempool so that no new messages will be received
on the mempool connection. This provides an opportunity to safely update all three states (Consensus,
Mempool and Info) to the latest committed state at once.
When commit
completes, it unlocks the mempool.
Warning
If the ABCI application logic processing the commit
message sends a /broadcast_tx_sync
or
/broadcast_tx_commit
and waits for the response before proceeding, it will deadlock. Executing those
broadcast_tx
calls involves acquiring a lock that is held during the commit
call, so it's not possible. If
you make the call to the broadcast_tx
endpoints concurrently, that's no problem, it just can't be part of the
sequential logic of the commit
function.
Provided methods
fn flush<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Signals that messages queued on the client should be flushed to the server.