reth_node_builder/
handle.rs

1use std::fmt;
2
3use reth_node_api::FullNodeComponents;
4use reth_node_core::exit::NodeExitFuture;
5
6use crate::{node::FullNode, rpc::RethRpcAddOns};
7
8/// A Handle to the launched node.
9#[must_use = "Needs to await the node exit future"]
10pub struct NodeHandle<Node: FullNodeComponents, AddOns: RethRpcAddOns<Node>> {
11    /// All node components.
12    pub node: FullNode<Node, AddOns>,
13    /// The exit future of the node.
14    pub node_exit_future: NodeExitFuture,
15}
16
17impl<Node, AddOns> NodeHandle<Node, AddOns>
18where
19    Node: FullNodeComponents,
20    AddOns: RethRpcAddOns<Node>,
21{
22    /// Waits for the node to exit, if it was configured to exit.
23    pub async fn wait_for_node_exit(self) -> eyre::Result<()> {
24        self.node_exit_future.await
25    }
26}
27
28impl<Node, AddOns> fmt::Debug for NodeHandle<Node, AddOns>
29where
30    Node: FullNodeComponents,
31    AddOns: RethRpcAddOns<Node>,
32{
33    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34        f.debug_struct("NodeHandle")
35            .field("node", &"...")
36            .field("node_exit_future", &self.node_exit_future)
37            .finish()
38    }
39}