call onleaf in verkle commit (#45)
This commit is contained in:
parent
99ebf767b9
commit
f215cc0791
@ -118,6 +118,16 @@ func (trie *VerkleTrie) Commit(onleaf LeafCallback) (common.Hash, int, error) {
|
|||||||
flush := make(chan verkle.VerkleNode)
|
flush := make(chan verkle.VerkleNode)
|
||||||
go func() {
|
go func() {
|
||||||
trie.root.(*verkle.InternalNode).Flush(func(n verkle.VerkleNode) {
|
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
|
flush <- n
|
||||||
})
|
})
|
||||||
close(flush)
|
close(flush)
|
||||||
@ -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
|
return trie.Hash(), commitCount, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user