Skip to content

Commit

Permalink
call onleaf in verkle commit (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed Jan 3, 2022
1 parent 99ebf76 commit f215cc0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion trie/verkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ func (trie *VerkleTrie) Commit(onleaf LeafCallback) (common.Hash, int, error) {
flush := make(chan verkle.VerkleNode)
go func() {
trie.root.(*verkle.InternalNode).Flush(func(n verkle.VerkleNode) {
if onleaf != nil {
if leaf, isLeaf := n.(*verkle.LeafNode); isLeaf {
for i := 0; i < verkle.NodeWidth; i++ {
if leaf.Value(i) != nil {
comm := n.ComputeCommitment().Bytes()
onleaf(nil, nil, leaf.Value(i), common.BytesToHash(comm[:]))
}
}
}
}
flush <- n
})
close(flush)
Expand All @@ -135,7 +145,6 @@ func (trie *VerkleTrie) Commit(onleaf LeafCallback) (common.Hash, int, error) {
}
}

// XXX onleaf hasn't been called
return trie.Hash(), commitCount, nil
}

Expand Down

0 comments on commit f215cc0

Please sign in to comment.