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:
@ -26,11 +26,9 @@ import (
|
||||
)
|
||||
|
||||
type hasher struct {
|
||||
tmp sliceBuffer
|
||||
sha keccakState
|
||||
cachegen uint16
|
||||
cachelimit uint16
|
||||
onleaf LeafCallback
|
||||
tmp sliceBuffer
|
||||
sha keccakState
|
||||
onleaf LeafCallback
|
||||
}
|
||||
|
||||
// keccakState wraps sha3.state. In addition to the usual hash methods, it also supports
|
||||
@ -62,9 +60,9 @@ var hasherPool = sync.Pool{
|
||||
},
|
||||
}
|
||||
|
||||
func newHasher(cachegen, cachelimit uint16, onleaf LeafCallback) *hasher {
|
||||
func newHasher(onleaf LeafCallback) *hasher {
|
||||
h := hasherPool.Get().(*hasher)
|
||||
h.cachegen, h.cachelimit, h.onleaf = cachegen, cachelimit, onleaf
|
||||
h.onleaf = onleaf
|
||||
return h
|
||||
}
|
||||
|
||||
@ -80,14 +78,13 @@ func (h *hasher) hash(n node, db *Database, force bool) (node, node, error) {
|
||||
if db == nil {
|
||||
return hash, n, nil
|
||||
}
|
||||
if n.canUnload(h.cachegen, h.cachelimit) {
|
||||
// Unload the node from cache. All of its subnodes will have a lower or equal
|
||||
// cache generation number.
|
||||
cacheUnloadCounter.Inc(1)
|
||||
return hash, hash, nil
|
||||
}
|
||||
if !dirty {
|
||||
return hash, n, nil
|
||||
switch n.(type) {
|
||||
case *fullNode, *shortNode:
|
||||
return hash, hash, nil
|
||||
default:
|
||||
return hash, n, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
// Trie not processed yet or needs storage, walk the children
|
||||
|
Reference in New Issue
Block a user