Skip to main content

Application

Trait Application 

Source
pub trait Application: Send + Sync {
    // Required method
    fn on_commit(&self, block: &Block) -> Result<()>;

    // Provided methods
    fn create_payload(&self) -> Vec<u8>  { ... }
    fn validate_block(&self, _block: &Block) -> bool { ... }
    fn validate_tx(&self, _tx: &[u8]) -> bool { ... }
    fn begin_block(&self, _height: Height, _view: ViewNumber) -> Result<()> { ... }
    fn deliver_tx(&self, _tx: &[u8]) -> Result<()> { ... }
    fn end_block(&self, _height: Height) -> Result<()> { ... }
    fn query(&self, _path: &str, _data: &[u8]) -> Result<Vec<u8>> { ... }
}
Expand description

ABCI-like application interface for the consensus engine.

The lifecycle for each block:

  1. begin_block — called when a new block is being proposed
  2. deliver_tx — called for each transaction in the payload
  3. end_block — called after all transactions are delivered
  4. on_commit — called when the block is finalized in the committed chain

For block validation:

  • validate_block — full block validation before voting
  • validate_tx — individual transaction validation for mempool

Required Methods§

Source

fn on_commit(&self, block: &Block) -> Result<()>

Called when a block is committed to the chain.

Provided Methods§

Source

fn create_payload(&self) -> Vec<u8>

Create a payload for a new block proposal. Typically pulls transactions from the mempool.

Source

fn validate_block(&self, _block: &Block) -> bool

Validate a proposed block before voting.

Source

fn validate_tx(&self, _tx: &[u8]) -> bool

Validate a single transaction for mempool admission.

Source

fn begin_block(&self, _height: Height, _view: ViewNumber) -> Result<()>

Called at the beginning of block execution.

Source

fn deliver_tx(&self, _tx: &[u8]) -> Result<()>

Called for each transaction in the block payload.

Source

fn end_block(&self, _height: Height) -> Result<()>

Called after all transactions in the block are delivered.

Source

fn query(&self, _path: &str, _data: &[u8]) -> Result<Vec<u8>>

Query application state (returns opaque bytes).

Implementors§