[−][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(&self, init_chain_request: InitChainRequest) -> InitChainResponse
Called once upon genesis. Usually used to establish initial (genesis) state.
fn begin_block(
&self,
begin_block_request: BeginBlockRequest
) -> BeginBlockResponse
&self,
begin_block_request: BeginBlockRequest
) -> BeginBlockResponse
Signals the beginning of a new block. Called prior to any deliver_tx s.
fn deliver_tx(
&self,
deliver_tx_request: DeliverTxRequest
) -> Result<DeliverTxResponse>
&self,
deliver_tx_request: DeliverTxRequest
) -> Result<DeliverTxResponse>
Execute the transaction in full. The workhorse of the application.
fn end_block(&self, end_block_request: EndBlockRequest) -> EndBlockResponse
Signals the end of a block. Called after all transactions, prior to each commit.
fn commit(&self) -> CommitResponse
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(&self)
Signals that messages queued on the client should be flushed to the server.