reth_node_builder/launch/
mod.rs

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