core, trie: rework trie database (#26813)

* core, trie: rework trie database

* trie: fix comment
This commit is contained in:
rjl493456442
2023-04-24 10:38:52 +03:00
committed by GitHub
parent 1e556d220c
commit bbcb5ea37b
10 changed files with 152 additions and 387 deletions
+6 -6
View File
@@ -420,17 +420,17 @@ func (st *StackTrie) hashRec(hasher *hasher, path []byte) {
return
case branchNode:
var nodes rawFullNode
var nodes fullNode
for i, child := range st.children {
if child == nil {
nodes[i] = nilValueNode
nodes.Children[i] = nilValueNode
continue
}
child.hashRec(hasher, append(path, byte(i)))
if len(child.val) < 32 {
nodes[i] = rawNode(child.val)
nodes.Children[i] = rawNode(child.val)
} else {
nodes[i] = hashNode(child.val)
nodes.Children[i] = hashNode(child.val)
}
// Release child back to pool.
@@ -444,7 +444,7 @@ func (st *StackTrie) hashRec(hasher *hasher, path []byte) {
case extNode:
st.children[0].hashRec(hasher, append(path, st.key...))
n := rawShortNode{Key: hexToCompact(st.key)}
n := shortNode{Key: hexToCompact(st.key)}
if len(st.children[0].val) < 32 {
n.Val = rawNode(st.children[0].val)
} else {
@@ -460,7 +460,7 @@ func (st *StackTrie) hashRec(hasher *hasher, path []byte) {
case leafNode:
st.key = append(st.key, byte(16))
n := rawShortNode{Key: hexToCompact(st.key), Val: valueNode(st.val)}
n := shortNode{Key: hexToCompact(st.key), Val: valueNode(st.val)}
n.encode(hasher.encbuf)
encodedNode = hasher.encodedBytes()