Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-atreya committed Oct 3, 2024
1 parent 4c3a783 commit a12c7db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/advanced/examples/reth_db_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use std::path::PathBuf;

/// We use the tower-like layering functionality that has been baked into the alloy-provider to
/// intercept the requests and redirect to the `RethDbProvider`.
pub(crate) struct RethDBLayer {
pub(crate) struct RethDbLayer {
db_path: PathBuf,
}

/// Initialize the `RethDBLayer` with the path to the reth datadir.
impl RethDBLayer {
impl RethDbLayer {
pub(crate) const fn new(db_path: PathBuf) -> Self {
Self { db_path }
}
Expand Down
11 changes: 7 additions & 4 deletions examples/advanced/examples/reth_db_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ use reth_provider::{
ProviderFactory, StateProvider, TryIntoHistoricalStateProvider,
};
mod reth_db_layer;
use reth_db_layer::RethDBLayer;
use reth_db_layer::RethDbLayer;

#[tokio::main]
async fn main() -> Result<()> {
run_with_tempdir("provider-call-reth-db", |data_dir| async move {
// Initialize reth node with a specific data directory
// Initializing reth with a tmp data directory.
// We use a tmp directory for the purposes of this example.
// This would actually use an existing reth datadir specified by `--datadir` when starting
// your reth node.
let reth = Reth::new()
.dev()
.disable_discovery()
Expand All @@ -53,7 +56,7 @@ async fn main() -> Result<()> {
// Any RPC method that is not implemented in the RethDbProvider gracefully falls back to the
// RPC provider specified in the `on_http` method.
let provider =
ProviderBuilder::new().layer(RethDBLayer::new(db_path)).on_http(reth.endpoint_url());
ProviderBuilder::new().layer(RethDbLayer::new(db_path)).on_http(reth.endpoint_url());

// Initialize the RPC provider to compare the time taken to fetch the results.
let rpc_provider = ProviderBuilder::new().on_http(reth.endpoint_url());
Expand Down Expand Up @@ -92,7 +95,7 @@ async fn main() -> Result<()> {
}

/// Implement the `ProviderLayer` trait for the `RethDBLayer` struct.
impl<P, T> ProviderLayer<P, T> for RethDBLayer
impl<P, T> ProviderLayer<P, T> for RethDbLayer
where
P: Provider<T>,
T: Transport + Clone,
Expand Down

0 comments on commit a12c7db

Please sign in to comment.