reth_node_builder/components/
mod.rsmod builder;
mod consensus;
mod engine;
mod execute;
mod network;
mod payload;
mod pool;
pub use builder::*;
pub use consensus::*;
pub use engine::*;
pub use execute::*;
pub use network::*;
pub use payload::*;
pub use pool::*;
use reth_consensus::Consensus;
use reth_evm::execute::BlockExecutorProvider;
use reth_network::NetworkHandle;
use reth_network_api::FullNetwork;
use reth_node_api::{EngineValidator, NodeTypesWithEngine};
use reth_payload_builder::PayloadBuilderHandle;
use reth_primitives::Header;
use reth_transaction_pool::TransactionPool;
use crate::{ConfigureEvm, FullNodeTypes};
pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'static {
type Pool: TransactionPool + Unpin;
type Evm: ConfigureEvm<Header = Header>;
type Executor: BlockExecutorProvider;
type Consensus: Consensus + Clone + Unpin + 'static;
type Network: FullNetwork;
type EngineValidator: EngineValidator<<T::Types as NodeTypesWithEngine>::Engine>;
fn pool(&self) -> &Self::Pool;
fn evm_config(&self) -> &Self::Evm;
fn block_executor(&self) -> &Self::Executor;
fn consensus(&self) -> &Self::Consensus;
fn network(&self) -> &Self::Network;
fn payload_builder(&self) -> &PayloadBuilderHandle<<T::Types as NodeTypesWithEngine>::Engine>;
fn engine_validator(&self) -> &Self::EngineValidator;
}
#[derive(Debug)]
pub struct Components<Node: FullNodeTypes, Pool, EVM, Executor, Consensus, Validator> {
pub transaction_pool: Pool,
pub evm_config: EVM,
pub executor: Executor,
pub consensus: Consensus,
pub network: NetworkHandle,
pub payload_builder: PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
pub engine_validator: Validator,
}
impl<Node, Pool, EVM, Executor, Cons, Val> NodeComponents<Node>
for Components<Node, Pool, EVM, Executor, Cons, Val>
where
Node: FullNodeTypes,
Pool: TransactionPool + Unpin + 'static,
EVM: ConfigureEvm<Header = Header>,
Executor: BlockExecutorProvider,
Cons: Consensus + Clone + Unpin + 'static,
Val: EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine> + Clone + Unpin + 'static,
{
type Pool = Pool;
type Evm = EVM;
type Executor = Executor;
type Consensus = Cons;
type Network = NetworkHandle;
type EngineValidator = Val;
fn pool(&self) -> &Self::Pool {
&self.transaction_pool
}
fn evm_config(&self) -> &Self::Evm {
&self.evm_config
}
fn block_executor(&self) -> &Self::Executor {
&self.executor
}
fn consensus(&self) -> &Self::Consensus {
&self.consensus
}
fn network(&self) -> &Self::Network {
&self.network
}
fn payload_builder(
&self,
) -> &PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine> {
&self.payload_builder
}
fn engine_validator(&self) -> &Self::EngineValidator {
&self.engine_validator
}
}
impl<Node, Pool, EVM, Executor, Cons, Val> Clone
for Components<Node, Pool, EVM, Executor, Cons, Val>
where
Node: FullNodeTypes,
Pool: TransactionPool,
EVM: ConfigureEvm<Header = Header>,
Executor: BlockExecutorProvider,
Cons: Consensus + Clone,
Val: EngineValidator<<Node::Types as NodeTypesWithEngine>::Engine>,
{
fn clone(&self) -> Self {
Self {
transaction_pool: self.transaction_pool.clone(),
evm_config: self.evm_config.clone(),
executor: self.executor.clone(),
consensus: self.consensus.clone(),
network: self.network.clone(),
payload_builder: self.payload_builder.clone(),
engine_validator: self.engine_validator.clone(),
}
}
}