reth_node_builder/components/
network.rs1use crate::{BuilderContext, FullNodeTypes};
4use reth_network::types::NetPrimitivesFor;
5use reth_network_api::FullNetwork;
6use reth_node_api::PrimitivesTy;
7use reth_transaction_pool::TransactionPool;
8use std::future::Future;
9
10pub trait NetworkBuilder<Node: FullNodeTypes, Pool: TransactionPool>: Send {
12 type Network: FullNetwork<Primitives: NetPrimitivesFor<PrimitivesTy<Node::Types>>>;
14
15 fn build_network(
17 self,
18 ctx: &BuilderContext<Node>,
19 pool: Pool,
20 ) -> impl Future<Output = eyre::Result<Self::Network>> + Send;
21}
22
23impl<Node, Net, F, Fut, Pool> NetworkBuilder<Node, Pool> for F
24where
25 Node: FullNodeTypes,
26 Net: FullNetwork<Primitives: NetPrimitivesFor<PrimitivesTy<Node::Types>>>,
27 Pool: TransactionPool,
28 F: Fn(&BuilderContext<Node>, Pool) -> Fut + Send,
29 Fut: Future<Output = eyre::Result<Net>> + Send,
30{
31 type Network = Net;
32
33 fn build_network(
34 self,
35 ctx: &BuilderContext<Node>,
36 pool: Pool,
37 ) -> impl Future<Output = eyre::Result<Net>> + Send {
38 self(ctx, pool)
39 }
40}