Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make FullNodeComponents Clone #8966

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions crates/exex/exex/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
use std::fmt::Debug;

use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeTypes};
use crate::{ExExEvent, ExExNotification};
use reth_node_api::FullNodeComponents;
use reth_node_core::node_config::NodeConfig;
use reth_primitives::Head;
use reth_tasks::TaskExecutor;
use std::fmt::Debug;
use tokio::sync::mpsc::{Receiver, UnboundedSender};

use crate::{ExExEvent, ExExNotification};

/// Captures the context that an `ExEx` has access to.
pub struct ExExContext<Node: FullNodeComponents> {
/// The current head of the blockchain at launch.
Expand Down Expand Up @@ -49,46 +47,39 @@ impl<Node: FullNodeComponents> Debug for ExExContext<Node> {
}
}

impl<Node: FullNodeComponents> NodeTypes for ExExContext<Node> {
type Primitives = Node::Primitives;
type Engine = Node::Engine;
}

impl<Node: FullNodeComponents> FullNodeTypes for ExExContext<Node> {
type DB = Node::DB;
type Provider = Node::Provider;
}

impl<Node: FullNodeComponents> FullNodeComponents for ExExContext<Node> {
type Pool = Node::Pool;
type Evm = Node::Evm;
type Executor = Node::Executor;

fn pool(&self) -> &Self::Pool {
impl<Node: FullNodeComponents> ExExContext<Node> {
/// Returns the transaction pool of the node.
pub fn pool(&self) -> &Node::Pool {
self.components.pool()
}

fn evm_config(&self) -> &Self::Evm {
/// Returns the node's evm config.
pub fn evm_config(&self) -> &Node::Evm {
self.components.evm_config()
}

fn block_executor(&self) -> &Self::Executor {
/// Returns the node's executor type.
pub fn block_executor(&self) -> &Node::Executor {
self.components.block_executor()
}

fn provider(&self) -> &Self::Provider {
/// Returns the provider of the node.
pub fn provider(&self) -> &Node::Provider {
self.components.provider()
}

fn network(&self) -> &reth_network::NetworkHandle {
/// Returns the handle to the network
pub fn network(&self) -> &reth_network::NetworkHandle {
self.components.network()
}

fn payload_builder(&self) -> &reth_payload_builder::PayloadBuilderHandle<Self::Engine> {
/// Returns the handle to the payload builder service.
pub fn payload_builder(&self) -> &reth_payload_builder::PayloadBuilderHandle<Node::Engine> {
self.components.payload_builder()
}

fn task_executor(&self) -> &TaskExecutor {
/// Returns the task executor.
pub fn task_executor(&self) -> &TaskExecutor {
self.components.task_executor()
}
}
2 changes: 1 addition & 1 deletion crates/node/api/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ where
}

/// Encapsulates all types and components of the node.
pub trait FullNodeComponents: FullNodeTypes + 'static {
pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
/// The transaction pool of the node.
type Pool: TransactionPool + Unpin;

Expand Down
Loading