arb_node/
network.rs

1//! Arbitrum network builder.
2
3use reth_chainspec::Hardforks;
4use reth_network::{primitives::BasicNetworkPrimitives, NetworkHandle, PeersInfo};
5use reth_node_builder::{components::NetworkBuilder, BuilderContext, FullNodeTypes, NodeTypes};
6use reth_node_types::PrimitivesTy;
7use reth_transaction_pool::{PoolPooledTx, PoolTransaction, TransactionPool};
8use tracing::info;
9
10/// Builder for Arbitrum P2P networking.
11///
12/// Delegates to reth's standard network stack.
13#[derive(Debug, Default, Clone, Copy)]
14pub struct ArbNetworkBuilder;
15
16impl<Node, Pool> NetworkBuilder<Node, Pool> for ArbNetworkBuilder
17where
18    Node: FullNodeTypes<Types: NodeTypes<ChainSpec: Hardforks>>,
19    Pool: TransactionPool<
20            Transaction: PoolTransaction<Consensus = reth_node_types::TxTy<Node::Types>>,
21        > + Unpin
22        + 'static,
23{
24    type Network =
25        NetworkHandle<BasicNetworkPrimitives<PrimitivesTy<Node::Types>, PoolPooledTx<Pool>>>;
26
27    async fn build_network(
28        self,
29        ctx: &BuilderContext<Node>,
30        pool: Pool,
31    ) -> eyre::Result<Self::Network> {
32        let network = ctx.network_builder().await?;
33        let handle = ctx.start_network(network, pool);
34        info!(target: "reth::cli", enode=%handle.local_node_record(), "P2P networking initialized");
35        Ok(handle)
36    }
37}