Merge pull request #121 from 0xPolygonMiden/hacka-simple-smt-parent-node-iterator

feat: add parent node iterator for SimpleSMT
This commit is contained in:
Augusto Hack
2023-04-05 00:46:32 +02:00
committed by GitHub
3 changed files with 71 additions and 11 deletions

View File

@@ -291,13 +291,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(),
},
);
}