From 7647ee218b03e90b1c2d9108b35fcb5e0eb96cbc Mon Sep 17 00:00:00 2001 From: Yulong Wu Date: Wed, 20 Nov 2024 16:39:45 +0000 Subject: [PATCH] Add overwrite_metadata --- .../src/rocks_db_with_merkle_tree/mod.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/radix-substate-store-impls/src/rocks_db_with_merkle_tree/mod.rs b/radix-substate-store-impls/src/rocks_db_with_merkle_tree/mod.rs index 8c9775da5b..cd42e80ac6 100644 --- a/radix-substate-store-impls/src/rocks_db_with_merkle_tree/mod.rs +++ b/radix-substate-store-impls/src/rocks_db_with_merkle_tree/mod.rs @@ -89,6 +89,12 @@ impl RocksDBWithMerkleTreeSubstateStore { }) .unwrap_or(Hash([0u8; Hash::LENGTH])) } + + pub fn overwrite_metadata(&mut self, meta: &Metadata) { + self.db + .put_cf(self.cf(META_CF), &[], scrypto_encode(meta).unwrap()) + .unwrap(); + } } impl SubstateDatabase for RocksDBWithMerkleTreeSubstateStore { @@ -303,9 +309,9 @@ impl ReadableTreeStore for RocksDBWithMerkleTreeSubstateStore { } #[derive(Debug, Clone, Hash, PartialEq, Eq, ScryptoSbor)] -struct Metadata { - current_state_version: u64, - current_state_root_hash: Hash, +pub struct Metadata { + pub current_state_version: u64, + pub current_state_root_hash: Hash, } #[cfg(test)]