trie/bintrie: fix Parent() to return parent hash, not current node

This commit is contained in:
CPerezz 2026-04-15 22:49:39 +02:00
parent c1fb257e2e
commit cff5fca22f
No known key found for this signature in database
GPG key ID: 62045F34B97177DD

View file

@ -173,7 +173,10 @@ func (it *binaryNodeIterator) Hash() common.Hash {
// Parent returns the hash of the parent of the current node. // Parent returns the hash of the parent of the current node.
func (it *binaryNodeIterator) Parent() common.Hash { func (it *binaryNodeIterator) Parent() common.Hash {
return it.store.ComputeHash(it.stack[len(it.stack)-1].Node) if len(it.stack) < 2 {
return common.Hash{}
}
return it.store.ComputeHash(it.stack[len(it.stack)-2].Node)
} }
// Path returns the hex-encoded path to the current node. // Path returns the hex-encoded path to the current node.