From 4350b69a18b32d7bb13337f12285ffe40380af33 Mon Sep 17 00:00:00 2001 From: Rostyslav Tyshko Date: Fri, 23 May 2025 15:49:27 -0400 Subject: [PATCH] add getters for block_id and commitment --- storage/src/lib.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/storage/src/lib.rs b/storage/src/lib.rs index 422365e..287edb9 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -403,6 +403,41 @@ impl RocksDBIO { Ok(data_blob_list) } + + pub fn get_snapshot_block_id(&self) -> DbResult { + let cf_snapshot = self.snapshot_column(); + let res = self + .db + .get_cf(&cf_snapshot, DB_SNAPSHOT_BLOCK_ID_KEY) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + + if let Some(data) = res { + Ok(u64::from_be_bytes(data.try_into().unwrap())) + } else { + Err(DbError::db_interaction_error( + "Snapshot block ID not found".to_string(), + )) + } + } + + pub fn get_snapshot_commitment(&self) -> DbResult> { + let cf_snapshot = self.snapshot_column(); + let res = self + .db + .get_cf(&cf_snapshot, DB_SNAPSHOT_COMMITMENT_KEY) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + + if let Some(data) = res { + Ok(data) + } else { + Err(DbError::db_interaction_error( + "Snapshot commitment not found".to_string(), + )) + } + } + + + } ///Creates address for sc data blob at corresponding id