pub trait BatchExecutor<DB> {
type Input<'a>;
type Output;
type Error;
// Required methods
fn execute_and_verify_one(
&mut self,
input: Self::Input<'_>,
) -> Result<(), Self::Error>;
fn finalize(self) -> Self::Output;
fn set_tip(&mut self, tip: BlockNumber);
fn set_prune_modes(&mut self, prune_modes: PruneModes);
fn size_hint(&self) -> Option<usize>;
// Provided methods
fn execute_and_verify_many<'a, I>(
&mut self,
inputs: I,
) -> Result<(), Self::Error>
where I: IntoIterator<Item = Self::Input<'a>> { ... }
fn execute_and_verify_batch<'a, I>(
self,
batch: I,
) -> Result<Self::Output, Self::Error>
where I: IntoIterator<Item = Self::Input<'a>>,
Self: Sized { ... }
}
Expand description
A general purpose executor that can execute multiple inputs in sequence, validate the outputs, and keep track of the state over the entire batch.
Required Associated Types§
Required Methods§
Sourcefn execute_and_verify_one(
&mut self,
input: Self::Input<'_>,
) -> Result<(), Self::Error>
fn execute_and_verify_one( &mut self, input: Self::Input<'_>, ) -> Result<(), Self::Error>
Executes the next block in the batch, verifies the output and updates the state internally.
Sourcefn set_tip(&mut self, tip: BlockNumber)
fn set_tip(&mut self, tip: BlockNumber)
Set the expected tip of the batch.
This can be used to optimize state pruning during execution.
Sourcefn set_prune_modes(&mut self, prune_modes: PruneModes)
fn set_prune_modes(&mut self, prune_modes: PruneModes)
Set the prune modes.
They are used to determine which parts of the state should be kept during execution.
Provided Methods§
Sourcefn execute_and_verify_many<'a, I>(
&mut self,
inputs: I,
) -> Result<(), Self::Error>where
I: IntoIterator<Item = Self::Input<'a>>,
fn execute_and_verify_many<'a, I>(
&mut self,
inputs: I,
) -> Result<(), Self::Error>where
I: IntoIterator<Item = Self::Input<'a>>,
Executes multiple inputs in the batch, verifies the output, and updates the state internally.
This method is a convenience function for calling BatchExecutor::execute_and_verify_one
for each input.
Sourcefn execute_and_verify_batch<'a, I>(
self,
batch: I,
) -> Result<Self::Output, Self::Error>
fn execute_and_verify_batch<'a, I>( self, batch: I, ) -> Result<Self::Output, Self::Error>
Executes the entire batch, verifies the output, and returns the final state.
This method is a convenience function for calling BatchExecutor::execute_and_verify_many
and BatchExecutor::finalize
.
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§
Source§impl<A, B, DB> BatchExecutor<DB> for Either<A, B>where
A: BatchExecutor<DB>,
B: for<'a> BatchExecutor<DB, Input<'a> = A::Input<'a>, Output = A::Output, Error = A::Error>,
DB: Database<Error: Into<ProviderError> + Display>,
impl<A, B, DB> BatchExecutor<DB> for Either<A, B>where
A: BatchExecutor<DB>,
B: for<'a> BatchExecutor<DB, Input<'a> = A::Input<'a>, Output = A::Output, Error = A::Error>,
DB: Database<Error: Into<ProviderError> + Display>,
type Input<'a> = <A as BatchExecutor<DB>>::Input<'a>
type Output = <A as BatchExecutor<DB>>::Output
type Error = <A as BatchExecutor<DB>>::Error
Source§impl<DB> BatchExecutor<DB> for MockExecutorProvider
Available on crate feature test-utils
only.
impl<DB> BatchExecutor<DB> for MockExecutorProvider
test-utils
only.