cmd, core, eth, trie: get rid of trie cache generations (#19262)
* cmd, core, eth, trie: get rid of trie cache generations * core, trie: get rid of remainder of cache gen boilerplate
This commit is contained in:
@ -154,11 +154,11 @@ func (n *cachedNode) rlp() []byte {
|
||||
|
||||
// obj returns the decoded and expanded trie node, either directly from the cache,
|
||||
// or by regenerating it from the rlp encoded blob.
|
||||
func (n *cachedNode) obj(hash common.Hash, cachegen uint16) node {
|
||||
func (n *cachedNode) obj(hash common.Hash) node {
|
||||
if node, ok := n.node.(rawNode); ok {
|
||||
return mustDecodeNode(hash[:], node, cachegen)
|
||||
return mustDecodeNode(hash[:], node)
|
||||
}
|
||||
return expandNode(hash[:], n.node, cachegen)
|
||||
return expandNode(hash[:], n.node)
|
||||
}
|
||||
|
||||
// childs returns all the tracked children of this node, both the implicit ones
|
||||
@ -223,16 +223,15 @@ func simplifyNode(n node) node {
|
||||
|
||||
// expandNode traverses the node hierarchy of a collapsed storage node and converts
|
||||
// all fields and keys into expanded memory form.
|
||||
func expandNode(hash hashNode, n node, cachegen uint16) node {
|
||||
func expandNode(hash hashNode, n node) node {
|
||||
switch n := n.(type) {
|
||||
case *rawShortNode:
|
||||
// Short nodes need key and child expansion
|
||||
return &shortNode{
|
||||
Key: compactToHex(n.Key),
|
||||
Val: expandNode(nil, n.Val, cachegen),
|
||||
Val: expandNode(nil, n.Val),
|
||||
flags: nodeFlag{
|
||||
hash: hash,
|
||||
gen: cachegen,
|
||||
},
|
||||
}
|
||||
|
||||
@ -241,12 +240,11 @@ func expandNode(hash hashNode, n node, cachegen uint16) node {
|
||||
node := &fullNode{
|
||||
flags: nodeFlag{
|
||||
hash: hash,
|
||||
gen: cachegen,
|
||||
},
|
||||
}
|
||||
for i := 0; i < len(node.Children); i++ {
|
||||
if n[i] != nil {
|
||||
node.Children[i] = expandNode(nil, n[i], cachegen)
|
||||
node.Children[i] = expandNode(nil, n[i])
|
||||
}
|
||||
}
|
||||
return node
|
||||
@ -349,13 +347,13 @@ func (db *Database) insertPreimage(hash common.Hash, preimage []byte) {
|
||||
|
||||
// node retrieves a cached trie node from memory, or returns nil if none can be
|
||||
// found in the memory cache.
|
||||
func (db *Database) node(hash common.Hash, cachegen uint16) node {
|
||||
func (db *Database) node(hash common.Hash) node {
|
||||
// Retrieve the node from the clean cache if available
|
||||
if db.cleans != nil {
|
||||
if enc, err := db.cleans.Get(string(hash[:])); err == nil && enc != nil {
|
||||
memcacheCleanHitMeter.Mark(1)
|
||||
memcacheCleanReadMeter.Mark(int64(len(enc)))
|
||||
return mustDecodeNode(hash[:], enc, cachegen)
|
||||
return mustDecodeNode(hash[:], enc)
|
||||
}
|
||||
}
|
||||
// Retrieve the node from the dirty cache if available
|
||||
@ -364,7 +362,7 @@ func (db *Database) node(hash common.Hash, cachegen uint16) node {
|
||||
db.lock.RUnlock()
|
||||
|
||||
if dirty != nil {
|
||||
return dirty.obj(hash, cachegen)
|
||||
return dirty.obj(hash)
|
||||
}
|
||||
// Content unavailable in memory, attempt to retrieve from disk
|
||||
enc, err := db.diskdb.Get(hash[:])
|
||||
@ -376,7 +374,7 @@ func (db *Database) node(hash common.Hash, cachegen uint16) node {
|
||||
memcacheCleanMissMeter.Mark(1)
|
||||
memcacheCleanWriteMeter.Mark(int64(len(enc)))
|
||||
}
|
||||
return mustDecodeNode(hash[:], enc, cachegen)
|
||||
return mustDecodeNode(hash[:], enc)
|
||||
}
|
||||
|
||||
// Node retrieves an encoded cached trie node from memory. If it cannot be found
|
||||
|
Reference in New Issue
Block a user