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::IntoFuture;
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>: Send {
25    /// The node type that is created.
26    type Node;
27
28    /// The future type that is returned.
29    type Future: IntoFuture<Output = eyre::Result<Self::Node>, IntoFuture: Send>;
30
31    /// Create and return a new node asynchronously.
32    fn launch_node(self, target: Target) -> Self::Future;
33}
34
35impl<F, Target, Fut, Node> LaunchNode<Target> for F
36where
37    F: FnOnce(Target) -> Fut + Send,
38    Fut: IntoFuture<Output = eyre::Result<Node>, IntoFuture: Send> + Send,
39{
40    type Node = Node;
41    type Future = Fut;
42
43    fn launch_node(self, target: Target) -> Self::Future {
44        self(target)
45    }
46}