Skip to content

Commit

Permalink
feat: add helper function to provde the tx manager config (paradigmxy…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Oct 9, 2024
1 parent 8396209 commit 67e83b6
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions crates/node/builder/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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<
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 67e83b6

Please sign in to comment.