Introduce SparseMerkleTree trait (#245)

This commit is contained in:
Philippe Laferrière
2024-01-18 16:02:02 -05:00
committed by Bobbin Threadbare
parent 1004246bfe
commit 8ea37904e3
13 changed files with 826 additions and 684 deletions

View File

@@ -173,7 +173,7 @@ impl<T: KvMap<RpoDigest, StoreNode>> MerkleStore<T> {
// the path is computed from root to leaf, so it must be reversed
path.reverse();
Ok(ValuePath::new(hash, path))
Ok(ValuePath::new(hash, MerklePath::new(path)))
}
// LEAF TRAVERSAL
@@ -490,8 +490,8 @@ impl<T: KvMap<RpoDigest, StoreNode>> From<&MerkleTree> for MerkleStore<T> {
}
}
impl<T: KvMap<RpoDigest, StoreNode>> From<&SimpleSmt> for MerkleStore<T> {
fn from(value: &SimpleSmt) -> Self {
impl<T: KvMap<RpoDigest, StoreNode>, const DEPTH: u8> From<&SimpleSmt<DEPTH>> for MerkleStore<T> {
fn from(value: &SimpleSmt<DEPTH>) -> Self {
let nodes = combine_nodes_with_empty_hashes(value.inner_nodes()).collect();
Self { nodes }
}