reth_node_builder/launch/mod.rs
1//! Abstraction for launching a node.
2
3pub mod common;
4mod exex;
5
6pub(crate) mod debug;
7pub(crate) mod engine;
8
9pub use common::LaunchContext;
10pub use exex::ExExLauncher;
11
12use std::future::Future;
13
14/// A general purpose trait that launches a new node of any kind.
15///
16/// Acts as a node factory that targets a certain node configuration and returns a handle to the
17/// node.
18///
19/// This is essentially the launch logic for a node.
20///
21/// See also [`EngineNodeLauncher`](crate::EngineNodeLauncher) and
22/// [`NodeBuilderWithComponents::launch_with`](crate::NodeBuilderWithComponents)
23pub trait LaunchNode<Target> {
24 /// The node type that is created.
25 type Node;
26
27 /// Create and return a new node asynchronously.
28 fn launch_node(self, target: Target) -> impl Future<Output = eyre::Result<Self::Node>>;
29}
30
31impl<F, Target, Fut, Node> LaunchNode<Target> for F
32where
33 F: FnOnce(Target) -> Fut + Send,
34 Fut: Future<Output = eyre::Result<Node>> + Send,
35{
36 type Node = Node;
37
38 fn launch_node(self, target: Target) -> impl Future<Output = eyre::Result<Self::Node>> {
39 self(target)
40 }
41}