pub trait Consensus: Send + Sync {
fn init_chain<'life0, 'async_trait>(
&'life0 self,
init_chain_request: RequestInitChain
) -> Pin<Box<dyn Future<Output = ResponseInitChain> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn begin_block<'life0, 'async_trait>(
&'life0 self,
begin_block_request: RequestBeginBlock
) -> Pin<Box<dyn Future<Output = ResponseBeginBlock> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn deliver_tx<'life0, 'async_trait>(
&'life0 self,
deliver_tx_request: RequestDeliverTx
) -> Pin<Box<dyn Future<Output = ResponseDeliverTx> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn end_block<'life0, 'async_trait>(
&'life0 self,
end_block_request: RequestEndBlock
) -> Pin<Box<dyn Future<Output = ResponseEndBlock> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn commit<'life0, 'async_trait>(
&'life0 self,
commit_request: RequestCommit
) -> Pin<Box<dyn Future<Output = ResponseCommit> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn echo<'life0, 'async_trait>(
&'life0 self,
echo_request: RequestEcho
) -> Pin<Box<dyn Future<Output = ResponseEcho> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait,
{ ... }
fn flush<'life0, 'async_trait>(
&'life0 self,
_flush_request: RequestFlush
) -> Pin<Box<dyn Future<Output = ResponseFlush> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait,
{ ... }
}
async-api
only.Expand description
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
sourcefn init_chain<'life0, 'async_trait>(
&'life0 self,
init_chain_request: RequestInitChain
) -> Pin<Box<dyn Future<Output = ResponseInitChain> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn init_chain<'life0, 'async_trait>(
&'life0 self,
init_chain_request: RequestInitChain
) -> Pin<Box<dyn Future<Output = ResponseInitChain> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Called once upon genesis. Usually used to establish initial (genesis) state.
Equivalent to
async fn init_chain(&self, init_chain_request: RequestInitChain) -> ResponseInitChain
sourcefn begin_block<'life0, 'async_trait>(
&'life0 self,
begin_block_request: RequestBeginBlock
) -> Pin<Box<dyn Future<Output = ResponseBeginBlock> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn begin_block<'life0, 'async_trait>(
&'life0 self,
begin_block_request: RequestBeginBlock
) -> Pin<Box<dyn Future<Output = ResponseBeginBlock> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Signals the beginning of a new block. Called prior to any deliver_tx
s.
Equivalent to
async fn begin_block(&self, begin_block_request: RequestBeginBlock) -> ResponseBeginBlock
sourcefn deliver_tx<'life0, 'async_trait>(
&'life0 self,
deliver_tx_request: RequestDeliverTx
) -> Pin<Box<dyn Future<Output = ResponseDeliverTx> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn deliver_tx<'life0, 'async_trait>(
&'life0 self,
deliver_tx_request: RequestDeliverTx
) -> Pin<Box<dyn Future<Output = ResponseDeliverTx> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Execute the transaction in full. The workhorse of the application.
Equivalent to
async fn deliver_tx(&self, deliver_tx_request: RequestDeliverTx) -> ResponseDeliverTx
sourcefn end_block<'life0, 'async_trait>(
&'life0 self,
end_block_request: RequestEndBlock
) -> Pin<Box<dyn Future<Output = ResponseEndBlock> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn end_block<'life0, 'async_trait>(
&'life0 self,
end_block_request: RequestEndBlock
) -> Pin<Box<dyn Future<Output = ResponseEndBlock> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Signals the end of a block. Called after all transactions, prior to each commit
.
Equivalent to
async fn end_block(&self, end_block_request: RequestEndBlock) -> ResponseEndBlock
sourcefn commit<'life0, 'async_trait>(
&'life0 self,
commit_request: RequestCommit
) -> Pin<Box<dyn Future<Output = ResponseCommit> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn commit<'life0, 'async_trait>(
&'life0 self,
commit_request: RequestCommit
) -> Pin<Box<dyn Future<Output = ResponseCommit> + 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.
Equivalent to
async fn commit(&self, commit_request: RequestCommit) -> ResponseCommit
Provided Methods
sourcefn echo<'life0, 'async_trait>(
&'life0 self,
echo_request: RequestEcho
) -> Pin<Box<dyn Future<Output = ResponseEcho> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn echo<'life0, 'async_trait>(
&'life0 self,
echo_request: RequestEcho
) -> Pin<Box<dyn Future<Output = ResponseEcho> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Echo a string to test abci client/server implementation.
Equivalent to
async fn echo(&self, echo_request: RequestEcho) -> ResponseEcho
sourcefn flush<'life0, 'async_trait>(
&'life0 self,
_flush_request: RequestFlush
) -> Pin<Box<dyn Future<Output = ResponseFlush> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn flush<'life0, 'async_trait>(
&'life0 self,
_flush_request: RequestFlush
) -> Pin<Box<dyn Future<Output = ResponseFlush> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Signals that messages queued on the client should be flushed to the server.
Equivalent to
async fn flush(&self, flush_request: RequestFlush) -> ResponseFlush