reth_node_builder/components/
mod.rsmod builder;
mod consensus;
mod execute;
mod network;
mod payload;
mod pool;
pub use builder::*;
pub use consensus::*;
pub use execute::*;
pub use network::*;
pub use payload::*;
pub use pool::*;
use crate::{ConfigureEvm, FullNodeTypes};
use alloy_consensus::Header;
use reth_consensus::Consensus;
use reth_evm::execute::BlockExecutorProvider;
use reth_network::NetworkHandle;
use reth_network_api::FullNetwork;
use reth_node_api::NodeTypesWithEngine;
use reth_payload_builder::PayloadBuilderHandle;
use reth_transaction_pool::TransactionPool;
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 PayloadBuilder: Clone;
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) -> &Self::PayloadBuilder;
}
#[derive(Debug)]
pub struct Components<Node: FullNodeTypes, Pool, EVM, Executor, Consensus> {
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>,
}
impl<Node, Pool, EVM, Executor, Cons> NodeComponents<Node>
for Components<Node, Pool, EVM, Executor, Cons>
where
Node: FullNodeTypes,
Pool: TransactionPool + Unpin + 'static,
EVM: ConfigureEvm<Header = Header>,
Executor: BlockExecutorProvider,
Cons: Consensus + Clone + Unpin + 'static,
{
type Pool = Pool;
type Evm = EVM;
type Executor = Executor;
type Consensus = Cons;
type Network = NetworkHandle;
type PayloadBuilder = PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>;
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) -> &Self::PayloadBuilder {
&self.payload_builder
}
}
impl<Node, Pool, EVM, Executor, Cons> Clone for Components<Node, Pool, EVM, Executor, Cons>
where
Node: FullNodeTypes,
Pool: TransactionPool,
EVM: ConfigureEvm<Header = Header>,
Executor: BlockExecutorProvider,
Cons: Consensus + Clone,
{
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(),
}
}
}