mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(sdk): enable referencing network type via FullNodeComponents::Network (#9921)
This commit is contained in:
@ -7,7 +7,7 @@ use reth_db_api::{
|
||||
database_metrics::{DatabaseMetadata, DatabaseMetrics},
|
||||
};
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_network::NetworkHandle;
|
||||
use reth_network::FullNetwork;
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_provider::FullProvider;
|
||||
use reth_tasks::TaskExecutor;
|
||||
@ -126,6 +126,9 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
|
||||
/// The type that knows how to execute blocks.
|
||||
type Executor: BlockExecutorProvider;
|
||||
|
||||
/// Network API.
|
||||
type Network: FullNetwork;
|
||||
|
||||
/// Returns the transaction pool of the node.
|
||||
fn pool(&self) -> &Self::Pool;
|
||||
|
||||
@ -139,12 +142,12 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
|
||||
fn provider(&self) -> &Self::Provider;
|
||||
|
||||
/// Returns the handle to the network
|
||||
fn network(&self) -> &NetworkHandle;
|
||||
fn network(&self) -> &Self::Network;
|
||||
|
||||
/// Returns the handle to the payload builder service.
|
||||
fn payload_builder(&self) -> &PayloadBuilderHandle<Self::Engine>;
|
||||
|
||||
/// Returns the task executor.
|
||||
/// Returns handle to runtime.
|
||||
fn task_executor(&self) -> &TaskExecutor;
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
use std::{fmt, future::Future, marker::PhantomData};
|
||||
|
||||
use reth_exex::ExExContext;
|
||||
use reth_network::NetworkHandle;
|
||||
use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes};
|
||||
use reth_node_core::{
|
||||
node_config::NodeConfig,
|
||||
@ -103,6 +102,7 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
|
||||
type Pool = C::Pool;
|
||||
type Evm = C::Evm;
|
||||
type Executor = C::Executor;
|
||||
type Network = C::Network;
|
||||
|
||||
fn pool(&self) -> &Self::Pool {
|
||||
self.components.pool()
|
||||
@ -120,7 +120,7 @@ impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeComponents for NodeAdapter<
|
||||
&self.provider
|
||||
}
|
||||
|
||||
fn network(&self) -> &NetworkHandle {
|
||||
fn network(&self) -> &Self::Network {
|
||||
self.components.network()
|
||||
}
|
||||
|
||||
|
||||
@ -7,19 +7,6 @@
|
||||
//!
|
||||
//! Components depend on a fully type configured node: [FullNodeTypes](crate::node::FullNodeTypes).
|
||||
|
||||
use crate::{ConfigureEvm, FullNodeTypes};
|
||||
pub use builder::*;
|
||||
pub use consensus::*;
|
||||
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_payload_builder::PayloadBuilderHandle;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
|
||||
mod builder;
|
||||
mod consensus;
|
||||
mod execute;
|
||||
@ -27,6 +14,21 @@ 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 reth_consensus::Consensus;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
use reth_network::{FullNetwork, NetworkHandle};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
|
||||
use crate::{ConfigureEvm, FullNodeTypes};
|
||||
|
||||
/// An abstraction over the components of a node, consisting of:
|
||||
/// - evm and executor
|
||||
/// - transaction pool
|
||||
@ -45,6 +47,9 @@ pub trait NodeComponents<NodeTypes: FullNodeTypes>: Clone + Unpin + Send + Sync
|
||||
/// The consensus type of the node.
|
||||
type Consensus: Consensus + Clone + Unpin + 'static;
|
||||
|
||||
/// Network API.
|
||||
type Network: FullNetwork;
|
||||
|
||||
/// Returns the transaction pool of the node.
|
||||
fn pool(&self) -> &Self::Pool;
|
||||
|
||||
@ -58,7 +63,7 @@ pub trait NodeComponents<NodeTypes: FullNodeTypes>: Clone + Unpin + Send + Sync
|
||||
fn consensus(&self) -> &Self::Consensus;
|
||||
|
||||
/// Returns the handle to the network
|
||||
fn network(&self) -> &NetworkHandle;
|
||||
fn network(&self) -> &Self::Network;
|
||||
|
||||
/// Returns the handle to the payload builder service.
|
||||
fn payload_builder(&self) -> &PayloadBuilderHandle<NodeTypes::Engine>;
|
||||
@ -96,6 +101,7 @@ where
|
||||
type Evm = EVM;
|
||||
type Executor = Executor;
|
||||
type Consensus = Cons;
|
||||
type Network = NetworkHandle;
|
||||
|
||||
fn pool(&self) -> &Self::Pool {
|
||||
&self.transaction_pool
|
||||
@ -113,7 +119,7 @@ where
|
||||
&self.consensus
|
||||
}
|
||||
|
||||
fn network(&self) -> &NetworkHandle {
|
||||
fn network(&self) -> &Self::Network {
|
||||
&self.network
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ use reth_blockchain_tree::{noop::NoopBlockchainTree, BlockchainTreeConfig};
|
||||
use reth_consensus_debug_client::{DebugConsensusClient, EtherscanBlockProvider, RpcBlockProvider};
|
||||
use reth_engine_util::EngineMessageStreamExt;
|
||||
use reth_exex::ExExManagerHandle;
|
||||
use reth_network::{BlockDownloaderProvider, NetworkEvents, NetworkHandle};
|
||||
use reth_network::{BlockDownloaderProvider, NetworkEvents};
|
||||
use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeAddOns};
|
||||
use reth_node_core::{
|
||||
dirs::{ChainPath, DataDirPath},
|
||||
@ -49,7 +49,7 @@ pub type EthApiBuilderCtx<N> = reth_rpc_eth_types::EthApiBuilderCtx<
|
||||
<N as FullNodeTypes>::Provider,
|
||||
<N as FullNodeComponents>::Pool,
|
||||
<N as FullNodeComponents>::Evm,
|
||||
NetworkHandle,
|
||||
<N as FullNodeComponents>::Network,
|
||||
TaskExecutor,
|
||||
<N as FullNodeTypes>::Provider,
|
||||
>;
|
||||
|
||||
@ -4,7 +4,6 @@ pub use reth_node_api::{FullNodeTypes, NodeTypes};
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_network::NetworkHandle;
|
||||
use reth_node_api::FullNodeComponents;
|
||||
use reth_node_core::{
|
||||
dirs::{ChainPath, DataDirPath},
|
||||
@ -91,7 +90,7 @@ pub struct FullNode<Node: FullNodeComponents, AddOns: NodeAddOns<Node>> {
|
||||
/// The node's transaction pool.
|
||||
pub pool: Node::Pool,
|
||||
/// Handle to the node's network.
|
||||
pub network: NetworkHandle,
|
||||
pub network: Node::Network,
|
||||
/// Provider to interact with the node's database
|
||||
pub provider: Node::Provider,
|
||||
/// Handle to the node's payload builder service.
|
||||
|
||||
@ -6,7 +6,6 @@ use std::{
|
||||
};
|
||||
|
||||
use futures::TryFutureExt;
|
||||
use reth_network::NetworkHandle;
|
||||
use reth_node_api::{BuilderProvider, FullNodeComponents};
|
||||
use reth_node_core::{
|
||||
node_config::NodeConfig,
|
||||
@ -161,7 +160,7 @@ pub struct RpcRegistry<Node: FullNodeComponents, EthApi> {
|
||||
pub(crate) registry: RpcRegistryInner<
|
||||
Node::Provider,
|
||||
Node::Pool,
|
||||
NetworkHandle,
|
||||
Node::Network,
|
||||
TaskExecutor,
|
||||
Node::Provider,
|
||||
EthApi,
|
||||
@ -172,7 +171,7 @@ impl<Node: FullNodeComponents, EthApi> Deref for RpcRegistry<Node, EthApi> {
|
||||
type Target = RpcRegistryInner<
|
||||
Node::Provider,
|
||||
Node::Pool,
|
||||
NetworkHandle,
|
||||
Node::Network,
|
||||
TaskExecutor,
|
||||
Node::Provider,
|
||||
EthApi,
|
||||
@ -241,7 +240,7 @@ impl<'a, Node: FullNodeComponents, EthApi> RpcContext<'a, Node, EthApi> {
|
||||
}
|
||||
|
||||
/// Returns the handle to the network
|
||||
pub fn network(&self) -> &NetworkHandle {
|
||||
pub fn network(&self) -> &Node::Network {
|
||||
self.node.network()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user