pub struct RocksDbStore {
db: DB,
}Expand description
RocksDB-backed JMT store with bounded memory usage.
Three column families:
jmt_nodes:borsh(NodeKey) -> borsh(Node)jmt_values:key_hash(32) || version(8 BE) -> raw value bytes(empty = tombstone)jmt_stale:stale_since_version(8 BE) || borsh(NodeKey) -> ()
The values CF key layout enables seek_for_prev to efficiently find the
latest value at or before a given version for a key hash.
Fields§
§db: DBImplementations§
Source§impl RocksDbStore
impl RocksDbStore
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Sourcepub fn write_tree_update_batch(&self, update: TreeUpdateBatch) -> Result<()>
pub fn write_tree_update_batch(&self, update: TreeUpdateBatch) -> Result<()>
Write a full TreeUpdateBatch atomically (nodes + values + stale indices).
Sourcepub fn prune(&self, up_to_version: Version) -> Result<(usize, usize)>
pub fn prune(&self, up_to_version: Version) -> Result<(usize, usize)>
Prune stale nodes up to (inclusive) the given version.
Value pruning is disabled by default until checkpoint compaction is
implemented. A dormant key can have its latest live value at an old
version, so deleting values by version alone can make the latest root
impossible to prove. The non-default prune-values feature keeps the
old experimental behavior available for research and benchmarks.
Returns (nodes_pruned, values_pruned).
fn prune_stale_nodes(&self, up_to_version: Version) -> Result<usize>
fn prune_values(&self, up_to_version: Version) -> Result<usize>
pub fn num_nodes(&self) -> Result<usize>
pub fn num_values(&self) -> Result<usize>
pub fn is_empty(&self) -> Result<bool>
Sourcepub fn copy_latest_root_to_version(&self, to_version: Version) -> Result<bool>
pub fn copy_latest_root_to_version(&self, to_version: Version) -> Result<bool>
Copy a JMT root node to a later version without changing tree contents.
JMT itself only writes a root node when a tree has updates. Runtime batches can still inherit an unchanged root, so checkpointing the root at the accepted version keeps exact-version startup verification cheap.
pub fn latest_root_version(&self) -> Result<Option<Version>>
fn latest_root_metadata(&self) -> Result<Option<(Version, Vec<u8>)>>
Sourcepub fn compact_all(&self) -> Result<()>
pub fn compact_all(&self) -> Result<()>
Compact all commitment-store column families.
This rewrites RocksDB’s LSM files after pruning or large batch runs so deleted stale-node keys stop occupying disk. It does not change logical JMT contents or versioned values.
fn count_cf(&self, cf_name: &str) -> Result<usize>
Trait Implementations§
Source§impl TreeReader for RocksDbStore
impl TreeReader for RocksDbStore
Source§fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>>
fn get_node_option(&self, node_key: &NodeKey) -> Result<Option<Node>>
None if the node does not exist.Source§fn get_value_option(
&self,
max_version: Version,
key_hash: KeyHash,
) -> Result<Option<OwnedValue>>
fn get_value_option( &self, max_version: Version, key_hash: KeyHash, ) -> Result<Option<OwnedValue>>
Source§fn get_rightmost_leaf(&self) -> Result<Option<(NodeKey, LeafNode)>>
fn get_rightmost_leaf(&self) -> Result<Option<(NodeKey, LeafNode)>>
Source§impl TreeWriter for RocksDbStore
impl TreeWriter for RocksDbStore
Source§fn write_node_batch(&self, node_batch: &NodeBatch) -> Result<()>
fn write_node_batch(&self, node_batch: &NodeBatch) -> Result<()>
Auto Trait Implementations§
impl Freeze for RocksDbStore
impl RefUnwindSafe for RocksDbStore
impl Send for RocksDbStore
impl Sync for RocksDbStore
impl Unpin for RocksDbStore
impl UnsafeUnpin for RocksDbStore
impl UnwindSafe for RocksDbStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more