Trait BlockBuilder

Source
pub trait BlockBuilder {
    type Primitives: NodePrimitives;
    type Executor: BlockExecutor<Transaction = TxTy<Self::Primitives>, Receipt = ReceiptTy<Self::Primitives>>;

    // Required methods
    fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError>;
    fn execute_transaction_with_result_closure(
        &mut self,
        tx: Recovered<TxTy<Self::Primitives>>,
        f: impl FnOnce(&ExecutionResult<<<Self::Executor as BlockExecutor>::Evm as Evm>::HaltReason>),
    ) -> Result<u64, BlockExecutionError>;
    fn finish(
        self,
        state_provider: impl StateProvider,
    ) -> Result<BlockBuilderOutcome<Self::Primitives>, BlockExecutionError>;
    fn executor_mut(&mut self) -> &mut Self::Executor;
    fn into_executor(self) -> Self::Executor;

    // Provided methods
    fn execute_transaction(
        &mut self,
        tx: Recovered<TxTy<Self::Primitives>>,
    ) -> Result<u64, BlockExecutionError> { ... }
    fn evm_mut(&mut self) -> &mut <Self::Executor as BlockExecutor>::Evm { ... }
}
Expand description

A type that knows how to execute and build a block.

It wraps an inner BlockExecutor and provides a way to execute transactions and construct a block.

This is a helper to erase BasicBlockBuilder type.

Required Associated Types§

Source

type Primitives: NodePrimitives

The primitive types used by the inner BlockExecutor.

Source

type Executor: BlockExecutor<Transaction = TxTy<Self::Primitives>, Receipt = ReceiptTy<Self::Primitives>>

Required Methods§

Source

fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError>

Source

fn execute_transaction_with_result_closure( &mut self, tx: Recovered<TxTy<Self::Primitives>>, f: impl FnOnce(&ExecutionResult<<<Self::Executor as BlockExecutor>::Evm as Evm>::HaltReason>), ) -> Result<u64, BlockExecutionError>

Invokes BlockExecutor::execute_transaction_with_result_closure and saves the transaction in internal state.

Source

fn finish( self, state_provider: impl StateProvider, ) -> Result<BlockBuilderOutcome<Self::Primitives>, BlockExecutionError>

Completes the block building process and returns the BlockBuilderOutcome.

Source

fn executor_mut(&mut self) -> &mut Self::Executor

Provides mutable access to the inner BlockExecutor.

Source

fn into_executor(self) -> Self::Executor

Consumes the type and returns the underlying BlockExecutor.

Provided Methods§

Source

fn execute_transaction( &mut self, tx: Recovered<TxTy<Self::Primitives>>, ) -> Result<u64, BlockExecutionError>

Invokes BlockExecutor::execute_transaction and saves the transaction in internal state.

Source

fn evm_mut(&mut self) -> &mut <Self::Executor as BlockExecutor>::Evm

Helper to access inner BlockExecutor::Evm.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§