mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
feat(cli): add reth db checksum rocksdb command (#21217)
Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9662dc5271
commit
ff8f434dcd
@@ -38,7 +38,7 @@ pub use consistent::ConsistentProvider;
|
||||
#[cfg_attr(not(all(unix, feature = "rocksdb")), path = "rocksdb_stub.rs")]
|
||||
pub(crate) mod rocksdb;
|
||||
|
||||
pub use rocksdb::{RocksDBBatch, RocksDBBuilder, RocksDBProvider, RocksTx};
|
||||
pub use rocksdb::{RocksDBBatch, RocksDBBuilder, RocksDBProvider, RocksDBRawIter, RocksTx};
|
||||
|
||||
/// Helper trait to bound [`NodeTypes`] so that combined with database they satisfy
|
||||
/// [`ProviderNodeTypes`].
|
||||
|
||||
@@ -5,4 +5,4 @@ mod metrics;
|
||||
mod provider;
|
||||
|
||||
pub(crate) use provider::{PendingRocksDBBatches, RocksDBWriteCtx};
|
||||
pub use provider::{RocksDBBatch, RocksDBBuilder, RocksDBProvider, RocksTx};
|
||||
pub use provider::{RocksDBBatch, RocksDBBuilder, RocksDBProvider, RocksDBRawIter, RocksTx};
|
||||
|
||||
@@ -656,6 +656,15 @@ impl RocksDBProvider {
|
||||
Ok(RocksDBIter { inner: iter, _marker: std::marker::PhantomData })
|
||||
}
|
||||
|
||||
/// Creates a raw iterator over all entries in the specified table.
|
||||
///
|
||||
/// Returns raw `(key_bytes, value_bytes)` pairs without decoding.
|
||||
pub fn raw_iter<T: Table>(&self) -> ProviderResult<RocksDBRawIter<'_>> {
|
||||
let cf = self.get_cf_handle::<T>()?;
|
||||
let iter = self.0.iterator_cf(cf, IteratorMode::Start);
|
||||
Ok(RocksDBRawIter { inner: iter })
|
||||
}
|
||||
|
||||
/// Returns all account history shards for the given address in ascending key order.
|
||||
///
|
||||
/// This is used for unwind operations where we need to scan all shards for an address
|
||||
@@ -1517,6 +1526,33 @@ impl<T: Table> Iterator for RocksDBIter<'_, T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Raw iterator over a `RocksDB` table (non-transactional).
|
||||
///
|
||||
/// Yields raw `(key_bytes, value_bytes)` pairs without decoding.
|
||||
pub struct RocksDBRawIter<'db> {
|
||||
inner: RocksDBIterEnum<'db>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for RocksDBRawIter<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("RocksDBRawIter").finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for RocksDBRawIter<'_> {
|
||||
type Item = ProviderResult<(Box<[u8]>, Box<[u8]>)>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
match self.inner.next()? {
|
||||
Ok(kv) => Some(Ok(kv)),
|
||||
Err(e) => Some(Err(ProviderError::Database(DatabaseError::Read(DatabaseErrorInfo {
|
||||
message: e.to_string().into(),
|
||||
code: -1,
|
||||
})))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterator over a `RocksDB` table within a transaction.
|
||||
///
|
||||
/// Yields decoded `(Key, Value)` pairs. Sees uncommitted writes.
|
||||
|
||||
@@ -116,3 +116,7 @@ impl RocksDBBuilder {
|
||||
/// A stub transaction for `RocksDB`.
|
||||
#[derive(Debug)]
|
||||
pub struct RocksTx;
|
||||
|
||||
/// A stub raw iterator for `RocksDB`.
|
||||
#[derive(Debug)]
|
||||
pub struct RocksDBRawIter;
|
||||
|
||||
Reference in New Issue
Block a user