1use crate::{execute::ExecutableTxFor, ConfigureEvm, EvmEnvFor, ExecutionCtxFor};
2use rayon::prelude::*;
3
4pub trait ConfigureEngineEvm<ExecutionData>: ConfigureEvm {
6 fn evm_env_for_payload(&self, payload: &ExecutionData) -> Result<EvmEnvFor<Self>, Self::Error>;
8
9 fn context_for_payload<'a>(
11 &self,
12 payload: &'a ExecutionData,
13 ) -> Result<ExecutionCtxFor<'a, Self>, Self::Error>;
14
15 fn tx_iterator_for_payload(
17 &self,
18 payload: &ExecutionData,
19 ) -> Result<impl ExecutableTxIterator<Self>, Self::Error>;
20}
21
22pub trait ExecutableTxTuple: Into<(Self::IntoIter, Self::Convert)> + Send + 'static {
26 type RawTx: Send + Sync + 'static;
31 type Tx: Clone + Send + Sync + 'static;
33 type Error: core::error::Error + Send + Sync + 'static;
35
36 type IntoIter: IntoParallelIterator<Item = Self::RawTx, Iter: IndexedParallelIterator>
38 + Send
39 + 'static;
40 type Convert: Fn(Self::RawTx) -> Result<Self::Tx, Self::Error> + Send + Sync + 'static;
44}
45
46impl<RawTx, Tx, Err, I, F> ExecutableTxTuple for (I, F)
47where
48 RawTx: Send + Sync + 'static,
49 Tx: Clone + Send + Sync + 'static,
50 Err: core::error::Error + Send + Sync + 'static,
51 I: IntoParallelIterator<Item = RawTx, Iter: IndexedParallelIterator> + Send + 'static,
52 F: Fn(RawTx) -> Result<Tx, Err> + Send + Sync + 'static,
53{
54 type RawTx = RawTx;
55 type Tx = Tx;
56 type Error = Err;
57
58 type IntoIter = I;
59 type Convert = F;
60}
61
62pub trait ExecutableTxIterator<Evm: ConfigureEvm>:
64 ExecutableTxTuple<Tx: ExecutableTxFor<Evm>>
65{
66}
67
68impl<T, Evm: ConfigureEvm> ExecutableTxIterator<Evm> for T where
69 T: ExecutableTxTuple<Tx: ExecutableTxFor<Evm>>
70{
71}