feat: add DatabaseMetrics trait for generic DB in reth node (#5690)

This commit is contained in:
Dan Cline
2023-12-11 17:28:56 -05:00
committed by GitHub
parent 64337f31e0
commit c1d7d2bde3
6 changed files with 81 additions and 47 deletions

View File

@ -153,7 +153,7 @@ pub fn open_db(path: &Path, log_level: Option<LogLevel>) -> eyre::Result<Databas
#[cfg(any(test, feature = "test-utils"))]
pub mod test_utils {
use super::*;
use crate::database::Database;
use crate::{database::Database, database_metrics::DatabaseMetrics};
use std::{path::PathBuf, sync::Arc};
/// Error during database open
@ -210,6 +210,12 @@ pub mod test_utils {
}
}
impl<DB: DatabaseMetrics> DatabaseMetrics for TempDatabase<DB> {
fn report_metrics(&self) {
self.db().report_metrics()
}
}
/// Create read/write database for testing
pub fn create_test_rw_db() -> Arc<TempDatabase<DatabaseEnv>> {
let path = tempfile::TempDir::new().expect(ERROR_TEMPDIR).into_path();