mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add helper function to provde the tx manager config (#11608)
This commit is contained in:
@ -9,6 +9,13 @@ pub use states::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
common::WithConfigs,
|
||||
components::NodeComponentsBuilder,
|
||||
node::FullNode,
|
||||
rpc::{EthApiBuilderProvider, RethRpcServerHandles, RpcContext},
|
||||
DefaultNodeLauncher, LaunchNode, Node, NodeHandle,
|
||||
};
|
||||
use futures::Future;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
|
||||
use reth_cli_util::get_secret_key;
|
||||
@ -18,7 +25,8 @@ use reth_db_api::{
|
||||
};
|
||||
use reth_exex::ExExContext;
|
||||
use reth_network::{
|
||||
NetworkBuilder, NetworkConfig, NetworkConfigBuilder, NetworkHandle, NetworkManager,
|
||||
transactions::TransactionsManagerConfig, NetworkBuilder, NetworkConfig, NetworkConfigBuilder,
|
||||
NetworkHandle, NetworkManager,
|
||||
};
|
||||
use reth_node_api::{
|
||||
FullNodeTypes, FullNodeTypesAdapter, NodeAddOns, NodeTypes, NodeTypesWithDBAdapter,
|
||||
@ -38,14 +46,6 @@ use reth_transaction_pool::{PoolConfig, TransactionPool};
|
||||
use secp256k1::SecretKey;
|
||||
use tracing::{info, trace, warn};
|
||||
|
||||
use crate::{
|
||||
common::WithConfigs,
|
||||
components::NodeComponentsBuilder,
|
||||
node::FullNode,
|
||||
rpc::{EthApiBuilderProvider, RethRpcServerHandles, RpcContext},
|
||||
DefaultNodeLauncher, LaunchNode, Node, NodeHandle,
|
||||
};
|
||||
|
||||
/// The adapter type for a reth node with the builtin provider type
|
||||
// Note: we need to hardcode this because custom components might depend on it in associated types.
|
||||
pub type RethFullAdapter<DB, Types> = FullNodeTypesAdapter<
|
||||
@ -583,16 +583,34 @@ impl<Node: FullNodeTypes> BuilderContext<Node> {
|
||||
self.config().builder.clone()
|
||||
}
|
||||
|
||||
/// Convenience function to start the network.
|
||||
/// Convenience function to start the network tasks.
|
||||
///
|
||||
/// Spawns the configured network and associated tasks and returns the [`NetworkHandle`]
|
||||
/// connected to that network.
|
||||
pub fn start_network<Pool>(&self, builder: NetworkBuilder<(), ()>, pool: Pool) -> NetworkHandle
|
||||
where
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
{
|
||||
self.start_network_with(builder, pool, Default::default())
|
||||
}
|
||||
|
||||
/// Convenience function to start the network tasks.
|
||||
///
|
||||
/// Accepts the config for the transaction task.
|
||||
///
|
||||
/// Spawns the configured network and associated tasks and returns the [`NetworkHandle`]
|
||||
/// connected to that network.
|
||||
pub fn start_network_with<Pool>(
|
||||
&self,
|
||||
builder: NetworkBuilder<(), ()>,
|
||||
pool: Pool,
|
||||
tx_config: TransactionsManagerConfig,
|
||||
) -> NetworkHandle
|
||||
where
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
{
|
||||
let (handle, network, txpool, eth) = builder
|
||||
.transactions(pool, Default::default())
|
||||
.transactions(pool, tx_config)
|
||||
.request_handler(self.provider().clone())
|
||||
.split_with_handle();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user