Skip to content

Commit

Permalink
simplify serve generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Dec 5, 2023
1 parent e715efd commit d654494
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions bin/reth/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use reth_blockchain_tree::{
config::BlockchainTreeConfig, externals::TreeExternals, BlockchainTree, ShareableBlockchainTree,
};
use reth_config::{config::PruneConfig, Config};
use reth_db::{database::Database, init_db, DatabaseEnv};
use reth_db::{database::Database, database_metrics::DatabaseMetrics, init_db, DatabaseEnv};
use reth_downloaders::{
bodies::bodies::BodiesDownloaderBuilder,
headers::reverse_headers::ReverseHeadersDownloaderBuilder,
Expand Down Expand Up @@ -690,10 +690,10 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
prometheus_exporter::install_recorder()
}

async fn start_metrics_endpoint(
async fn start_metrics_endpoint<DB: DatabaseMetrics + 'static>(
&self,
prometheus_handle: PrometheusHandle,
db: Arc<DatabaseEnv>,
db: Arc<DB>,
) -> eyre::Result<()> {
if let Some(listen_addr) = self.metrics {
info!(target: "reth::cli", addr = %listen_addr, "Starting metrics endpoint");
Expand Down Expand Up @@ -806,15 +806,15 @@ impl<Ext: RethCliExt> NodeCommand<Ext> {
// try to look up the header in the database
if let Some(header) = header {
info!(target: "reth::cli", ?tip, "Successfully looked up tip block in the database");
return Ok(header.seal_slow())
return Ok(header.seal_slow());
}

info!(target: "reth::cli", ?tip, "Fetching tip block from the network.");
loop {
match get_single_header(&client, tip).await {
Ok(tip_header) => {
info!(target: "reth::cli", ?tip, "Successfully fetched tip");
return Ok(tip_header)
return Ok(tip_header);
}
Err(error) => {
error!(target: "reth::cli", %error, "Failed to fetch the tip. Retrying...");
Expand Down
4 changes: 2 additions & 2 deletions bin/reth/src/prometheus_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use hyper::{
use metrics::{describe_gauge, gauge};
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
use metrics_util::layers::{PrefixLayer, Stack};
use reth_db::{database::Database, database_metrics::DatabaseMetrics};
use reth_db::database_metrics::DatabaseMetrics;
use reth_metrics::metrics::Unit;
use std::{convert::Infallible, net::SocketAddr, sync::Arc};
use tracing::error;
Expand Down Expand Up @@ -74,7 +74,7 @@ async fn start_endpoint<F: Hook + 'static>(
}

/// Serves Prometheus metrics over HTTP with database and process metrics.
pub(crate) async fn serve<DB: Database + DatabaseMetrics + 'static>(
pub(crate) async fn serve<DB: DatabaseMetrics + 'static>(
listen_addr: SocketAddr,
handle: PrometheusHandle,
db: Arc<DB>,
Expand Down

0 comments on commit d654494

Please sign in to comment.