Skip to content

Commit

Permalink
Merge branch 'oss' into revertible_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Trantorian committed Apr 24, 2024
2 parents 4354c6d + f92d341 commit 3bfe812
Show file tree
Hide file tree
Showing 3 changed files with 509 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/key_value_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ where
Ok(self.db.get(&key.into())?)
}

pub(crate) fn get_latest_id(&self) -> Option<ID> {
self.changes_store.id_queue.back().cloned()
}

pub(crate) fn contains(
&self,
key: &TrieKey,
Expand Down
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,20 @@ where
self.tries.get_keys(identifier)
}

/// Get all the key-value pairs in a specific trie.
#[allow(clippy::type_complexity)]
pub fn get_key_value_pairs(
&self,
identifier: &[u8],
) -> Result<Vec<(Vec<u8>, Vec<u8>)>, BonsaiStorageError<DB::DatabaseError>> {
self.tries.get_key_value_pairs(identifier)
}

/// Get the id from the latest commit, or `None` if no commit has taken place yet.
pub fn get_latest_id(&self) -> Option<ChangeID> {
self.tries.db_ref().get_latest_id()
}

/// Verifies a merkle-proof for a given `key` and `value`.
pub fn verify_proof(
root: Felt,
Expand Down
Loading

0 comments on commit 3bfe812

Please sign in to comment.