diff --git a/crates/cnidarium/src/storage.rs b/crates/cnidarium/src/storage.rs index 500245c8d7..ca5108fcf4 100644 --- a/crates/cnidarium/src/storage.rs +++ b/crates/cnidarium/src/storage.rs @@ -46,6 +46,9 @@ struct Inner { db: Arc, } +/// A staged write batch that can be committed to RocksDB. +/// +/// This allows for write batches to be prepared and committed at a later time. pub struct StagedWriteBatch { /// The write batch to commit to RocksDB. pub(crate) write_batch: rocksdb::WriteBatch, @@ -65,6 +68,18 @@ pub struct StagedWriteBatch { pub(crate) changes: Arc, } +impl StagedWriteBatch { + /// Returns the new version of the chain state corresponding to this set of changes. + pub fn version(&self) -> jmt::Version { + self.version + } + + /// Returns the root hash of the jmt corresponding to this set of changes. + pub fn root_hash(&self) -> &RootHash { + &self.root_hash + } +} + impl Storage { /// Loads a storage instance from the given path, initializing it if necessary. pub async fn load(path: PathBuf, default_prefixes: Vec) -> Result {