pub trait Dispatcher: Send + Sync {
    // Required methods
    fn execute_batch(
        &self,
        ctx: Context<'_>,
        batch: &TxnBatch,
        in_msgs: &[IncomingMessage],
    ) -> Result<ExecuteBatchResult, RuntimeError>;
    fn check_batch(
        &self,
        ctx: Context<'_>,
        batch: &TxnBatch,
    ) -> Result<Vec<CheckTxResult>, RuntimeError>;

    // Provided methods
    fn is_supported(&self) -> bool { ... }
    fn schedule_and_execute_batch(
        &self,
        _ctx: Context<'_>,
        _initial_batch: &mut TxnBatch,
        _in_msgs: &[IncomingMessage],
    ) -> Result<ExecuteBatchResult, RuntimeError> { ... }
    fn finalize(&self, _new_storage_root: Hash) { ... }
    fn set_abort_batch_flag(&mut self, _abort_batch: Arc<AtomicBool>) { ... }
    fn query(
        &self,
        _ctx: Context<'_>,
        _method: &str,
        _args: Vec<u8>,
    ) -> Result<Vec<u8>, RuntimeError> { ... }
}
Expand description

Runtime transaction dispatcher trait.

It defines the interface used by the runtime call dispatcher to process transactions.

Required Methods§

source

fn execute_batch( &self, ctx: Context<'_>, batch: &TxnBatch, in_msgs: &[IncomingMessage], ) -> Result<ExecuteBatchResult, RuntimeError>

Execute the transactions in the given batch.

§Consensus Layer State Integrity

Before this method is invoked, consensus layer state integrity verification is performed.

source

fn check_batch( &self, ctx: Context<'_>, batch: &TxnBatch, ) -> Result<Vec<CheckTxResult>, RuntimeError>

Check the transactions in the given batch for validity.

§Consensus Layer State Integrity

No consensus layer state integrity verification is performed for queries by default. The runtime dispatcher implementation should perform integrity verification if needed on a query-by-query basis.

Provided Methods§

source

fn is_supported(&self) -> bool

Whether dispatch is supported by this dispatcher.

source

fn schedule_and_execute_batch( &self, _ctx: Context<'_>, _initial_batch: &mut TxnBatch, _in_msgs: &[IncomingMessage], ) -> Result<ExecuteBatchResult, RuntimeError>

Schedule and execute transactions in the given batch.

The passed batch is an initial batch. In case the runtime needs additional items it should request them from the host.

§Consensus Layer State Integrity

Before this method is invoked, consensus layer state integrity verification is performed.

source

fn finalize(&self, _new_storage_root: Hash)

Invoke the finalizer (if any).

source

fn set_abort_batch_flag(&mut self, _abort_batch: Arc<AtomicBool>)

Configure abort batch flag.

source

fn query( &self, _ctx: Context<'_>, _method: &str, _args: Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>

Process a query.

§Consensus Layer State Integrity

No consensus layer state integrity verification is performed for queries by default. The runtime dispatcher implementation should perform integrity verification if needed on a query-by-query basis.

Implementations on Foreign Types§

source§

impl<T: Dispatcher + ?Sized> Dispatcher for Box<T>

source§

fn execute_batch( &self, ctx: Context<'_>, batch: &TxnBatch, in_msgs: &[IncomingMessage], ) -> Result<ExecuteBatchResult, RuntimeError>

source§

fn schedule_and_execute_batch( &self, ctx: Context<'_>, initial_batch: &mut TxnBatch, in_msgs: &[IncomingMessage], ) -> Result<ExecuteBatchResult, RuntimeError>

source§

fn check_batch( &self, ctx: Context<'_>, batch: &TxnBatch, ) -> Result<Vec<CheckTxResult>, RuntimeError>

source§

fn finalize(&self, new_storage_root: Hash)

source§

fn set_abort_batch_flag(&mut self, abort_batch: Arc<AtomicBool>)

source§

fn query( &self, ctx: Context<'_>, method: &str, args: Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>

source§

impl<T: Dispatcher + ?Sized> Dispatcher for Arc<T>

source§

fn execute_batch( &self, ctx: Context<'_>, batch: &TxnBatch, in_msgs: &[IncomingMessage], ) -> Result<ExecuteBatchResult, RuntimeError>

source§

fn schedule_and_execute_batch( &self, ctx: Context<'_>, initial_batch: &mut TxnBatch, in_msgs: &[IncomingMessage], ) -> Result<ExecuteBatchResult, RuntimeError>

source§

fn check_batch( &self, ctx: Context<'_>, batch: &TxnBatch, ) -> Result<Vec<CheckTxResult>, RuntimeError>

source§

fn finalize(&self, new_storage_root: Hash)

source§

fn set_abort_batch_flag(&mut self, _abort_batch: Arc<AtomicBool>)

source§

fn query( &self, ctx: Context<'_>, method: &str, args: Vec<u8>, ) -> Result<Vec<u8>, RuntimeError>

Implementors§