mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 00:58:11 -05:00
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
//! Example for how hook into the node via the CLI extension mechanism without registering
|
||
//! additional arguments
|
||
//!
|
||
//! Run with
|
||
//!
|
||
//! ```sh
|
||
//! cargo run -p node-event-hooks -- node
|
||
//! ```
|
||
//!
|
||
//! This launches a regular reth node and also print:
|
||
//! > "All components initialized" – once all components have been initialized
|
||
//! > "Node started" – once the node has been started.
|
||
|
||
#![warn(unused_crate_dependencies)]
|
||
|
||
use reth_ethereum::{cli::interface::Cli, node::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();
|
||
}
|