Files
reth/examples/node-event-hooks/src/main.rs
Matthias Seitz 4250c33da1 chore: clippy happy (#8362)
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
2024-05-23 13:24:20 +02:00

41 lines
1.1 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Example for how hook into the node via the CLI extension mechanism without registering
//! additional arguments
//!
//! Run with
//!
//! ```not_rust
//! cargo run -p node-event-hooks -- node
//! ```
//!
//! This launch the regular reth node and also print:
//! > "All components initialized" once all components have been initialized
//! > "Node started" once the node has been started.
use reth::cli::Cli;
use reth_node_ethereum::EthereumNode;
fn main() {
Cli::parse_args()
.run(|builder, _| async move {
let handle = builder
.node(EthereumNode::default())
.on_node_started(|_ctx| {
println!("Node started");
Ok(())
})
.on_rpc_started(|_ctx, _handles| {
println!("RPC started");
Ok(())
})
.on_component_initialized(|_ctx| {
println!("All components initialized");
Ok(())
})
.launch()
.await?;
handle.wait_for_node_exit().await
})
.unwrap();
}