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