mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
trie/bintrie: deserialize zero hashes as Empty nodes instead of HashedNode
This commit is contained in:
parent
b04df226fa
commit
47f4e5625a
1 changed files with 9 additions and 2 deletions
|
|
@ -101,10 +101,17 @@ func DeserializeNode(serialized []byte, depth int) (BinaryNode, error) {
|
||||||
if len(serialized) != 65 {
|
if len(serialized) != 65 {
|
||||||
return nil, invalidSerializedLength
|
return nil, invalidSerializedLength
|
||||||
}
|
}
|
||||||
|
var left, right BinaryNode = Empty{}, Empty{}
|
||||||
|
if leftHash := common.BytesToHash(serialized[1:33]); leftHash != (common.Hash{}) {
|
||||||
|
left = HashedNode(leftHash)
|
||||||
|
}
|
||||||
|
if rightHash := common.BytesToHash(serialized[33:65]); rightHash != (common.Hash{}) {
|
||||||
|
right = HashedNode(rightHash)
|
||||||
|
}
|
||||||
return &InternalNode{
|
return &InternalNode{
|
||||||
depth: depth,
|
depth: depth,
|
||||||
left: HashedNode(common.BytesToHash(serialized[1:33])),
|
left: left,
|
||||||
right: HashedNode(common.BytesToHash(serialized[33:65])),
|
right: right,
|
||||||
}, nil
|
}, nil
|
||||||
case nodeTypeStem:
|
case nodeTypeStem:
|
||||||
if len(serialized) < 64 {
|
if len(serialized) < 64 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue