mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: rm unused databasemetadata trait (#14003)
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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`.
|
||||
///
|
||||
|
||||
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user