mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
refactor: rename some examples (#7881)
This commit is contained in:
committed by
GitHub
parent
29e5df81a4
commit
1c81fae4d1
10
examples/node-event-hooks/Cargo.toml
Normal file
10
examples/node-event-hooks/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "node-event-hooks"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
reth.workspace = true
|
||||
reth-node-ethereum.workspace = true
|
||||
44
examples/node-event-hooks/src/main.rs
Normal file
44
examples/node-event-hooks/src/main.rs
Normal file
@ -0,0 +1,44 @@
|
||||
//! 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 and
|
||||
//!
|
||||
//! > "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();
|
||||
}
|
||||
Reference in New Issue
Block a user