feat: add parent node iterator for SimpleSMT

This commit is contained in:
Augusto F. Hack
2023-04-03 19:08:42 +02:00
parent f19fe6e739
commit 9275dd00ad
3 changed files with 71 additions and 11 deletions

View File

@@ -281,13 +281,12 @@ impl MerkleStore {
I: Iterator<Item = (u64, Word)> + ExactSizeIterator,
{
let smt = SimpleSmt::new(depth)?.with_leaves(entries)?;
for branch in smt.branches.values() {
let parent = Rpo256::merge(&[branch.left, branch.right]);
for node in smt.inner_nodes() {
self.nodes.insert(
parent,
node.value.into(),
Node {
left: branch.left,
right: branch.right,
left: node.left.into(),
right: node.right.into(),
},
);
}