chore: rm unused databasemetadata trait (#14003)

This commit is contained in:
Matthias Seitz
2025-01-27 13:22:07 +01:00
committed by GitHub
parent d858a9f87d
commit b9a6e65d8c
8 changed files with 16 additions and 77 deletions

View File

@ -40,35 +40,3 @@ impl<DB: DatabaseMetrics> DatabaseMetrics for Arc<DB> {
<DB as DatabaseMetrics>::report_metrics(self)
}
}
/// The type used to store metadata about the database.
#[derive(Debug, Default)]
pub struct DatabaseMetadataValue {
/// The freelist size
freelist_size: Option<usize>,
}
impl DatabaseMetadataValue {
/// Creates a new [`DatabaseMetadataValue`] with the given freelist size.
pub const fn new(freelist_size: Option<usize>) -> Self {
Self { freelist_size }
}
/// Returns the freelist size, if available.
pub const fn freelist_size(&self) -> Option<usize> {
self.freelist_size
}
}
/// Includes a method to return a [`DatabaseMetadataValue`] type, which can be used to dynamically
/// retrieve information about the database.
pub trait DatabaseMetadata {
/// Returns a metadata type, [`DatabaseMetadataValue`] for the database.
fn metadata(&self) -> DatabaseMetadataValue;
}
impl<DB: DatabaseMetadata> DatabaseMetadata for Arc<DB> {
fn metadata(&self) -> DatabaseMetadataValue {
<DB as DatabaseMetadata>::metadata(self)
}
}

View File

@ -12,7 +12,7 @@ use metrics::{gauge, Label};
use reth_db_api::{
cursor::{DbCursorRO, DbCursorRW},
database::Database,
database_metrics::{DatabaseMetadata, DatabaseMetadataValue, DatabaseMetrics},
database_metrics::DatabaseMetrics,
models::ClientVersion,
transaction::{DbTx, DbTxMut},
};
@ -276,12 +276,6 @@ impl DatabaseMetrics for DatabaseEnv {
}
}
impl DatabaseMetadata for DatabaseEnv {
fn metadata(&self) -> DatabaseMetadataValue {
DatabaseMetadataValue::new(self.freelist().ok())
}
}
impl DatabaseEnv {
/// Opens the database at the specified path with the given `EnvKind`.
///

View File

@ -46,9 +46,7 @@ pub mod test_utils {
use crate::mdbx::DatabaseArguments;
use parking_lot::RwLock;
use reth_db_api::{
database::Database,
database_metrics::{DatabaseMetadata, DatabaseMetadataValue, DatabaseMetrics},
models::ClientVersion,
database::Database, database_metrics::DatabaseMetrics, models::ClientVersion,
};
use reth_fs_util;
use reth_libmdbx::MaxReadTransactionDuration;
@ -155,12 +153,6 @@ pub mod test_utils {
}
}
impl<DB: DatabaseMetadata> DatabaseMetadata for TempDatabase<DB> {
fn metadata(&self) -> DatabaseMetadataValue {
self.db().metadata()
}
}
/// Create `static_files` path for testing
#[track_caller]
pub fn create_test_static_files_dir() -> (TempDir, PathBuf) {