Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ members = [
"examples/network-txpool/",
"examples/network/",
"examples/network-proxy/",
"examples/node-builder-api/",
"examples/node-custom-rpc/",
"examples/node-event-hooks/",
"examples/op-db-access/",
Expand Down
1 change: 1 addition & 0 deletions crates/ethereum/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ node = [
"provider",
"consensus",
"evm",
"network",
"node-api",
"dep:reth-node-ethereum",
"dep:reth-node-builder",
Expand Down
7 changes: 7 additions & 0 deletions crates/node/builder/src/components/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ impl<Tx> Default for NoopTransactionPoolBuilder<Tx> {
#[derive(Debug, Clone)]
pub struct NoopNetworkBuilder<Net = EthNetworkPrimitives>(PhantomData<Net>);

impl NoopNetworkBuilder {
/// Returns the instance with ethereum types.
pub fn eth() -> Self {
Self::default()
}
}

impl<N, Pool, Net> NetworkBuilder<N, Pool> for NoopNetworkBuilder<Net>
where
N: FullNodeTypes,
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ node = [
"provider",
"consensus",
"evm",
"network",
"node-api",
"dep:reth-optimism-node",
"dep:reth-node-builder",
Expand Down
12 changes: 12 additions & 0 deletions examples/node-builder-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "example-node-builder-api"
version = "0.0.0"
publish = false
edition.workspace = true
license.workspace = true

[dependencies]
reth-ethereum = { workspace = true, features = ["node", "pool", "node-api", "cli", "test-utils"] }
reth-tracing.workspace = true

eyre.workspace = true
29 changes: 29 additions & 0 deletions examples/node-builder-api/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! This example showcases various Nodebuilder use cases

use reth_ethereum::{
cli::interface::Cli,
node::{builder::components::NoopNetworkBuilder, node::EthereumAddOns, EthereumNode},
};

/// Maps the ethereum node's network component to the noop implementation.
///
/// This installs the [`NoopNetworkBuilder`] that does not launch a real network.
pub fn noop_network() {
Cli::parse_args()
.run(|builder, _| async move {
let handle = builder
// use the default ethereum node types
.with_types::<EthereumNode>()
// Configure the components of the node
// use default ethereum components but use the Noop network that does nothing but
.with_components(EthereumNode::components().network(NoopNetworkBuilder::eth()))
.with_add_ons(EthereumAddOns::default())
.launch()
.await?;

handle.wait_for_node_exit().await
})
.unwrap();
}

fn main() {}
Loading