mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
trie: only cache one rlp per hash (even from diff owners)
This commit is contained in:
parent
0ef6607045
commit
a32e4c7f69
2 changed files with 7 additions and 6 deletions
|
|
@ -462,7 +462,7 @@ func (db *Database) node(owner common.Hash, hash common.Hash, cachegen uint16) n
|
|||
|
||||
// Retrieve the node from the clean cache if available
|
||||
if db.cleans != nil {
|
||||
if enc, err := db.cleans.Get(key); err == nil && enc != 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)
|
||||
|
|
@ -482,7 +482,7 @@ func (db *Database) node(owner common.Hash, hash common.Hash, cachegen uint16) n
|
|||
return nil
|
||||
}
|
||||
if db.cleans != nil {
|
||||
db.cleans.Set(key, enc)
|
||||
db.cleans.Set(string(hash[:]), enc)
|
||||
memcacheCleanMissMeter.Mark(1)
|
||||
memcacheCleanWriteMeter.Mark(int64(len(enc)))
|
||||
}
|
||||
|
|
@ -496,7 +496,7 @@ func (db *Database) Node(owner common.Hash, hash common.Hash) ([]byte, error) {
|
|||
|
||||
// Retrieve the node from the clean cache if available
|
||||
if db.cleans != nil {
|
||||
if enc, err := db.cleans.Get(key); err == nil && enc != nil {
|
||||
if enc, err := db.cleans.Get(string(hash[:])); err == nil && enc != nil {
|
||||
memcacheCleanHitMeter.Mark(1)
|
||||
memcacheCleanReadMeter.Mark(int64(len(enc)))
|
||||
return enc, nil
|
||||
|
|
@ -514,7 +514,7 @@ func (db *Database) Node(owner common.Hash, hash common.Hash) ([]byte, error) {
|
|||
enc, err := db.diskdb.Get([]byte(key))
|
||||
if err == nil && enc != nil {
|
||||
if db.cleans != nil {
|
||||
db.cleans.Set(key, enc)
|
||||
db.cleans.Set(string(hash[:]), enc)
|
||||
memcacheCleanMissMeter.Mark(1)
|
||||
memcacheCleanWriteMeter.Mark(int64(len(enc)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ func (p *pruner) prune(owner common.Hash, hash common.Hash, path []byte) {
|
|||
node := mustDecodeNode(hash[:], blob, 0)
|
||||
|
||||
// Prune the node and its children if it's not a bytecode blob
|
||||
p.db.cleans.Delete(key)
|
||||
p.db.cleans.Delete(string(hash[:]))
|
||||
p.batch.Delete(dead)
|
||||
p.db.prunenodes++
|
||||
p.db.prunesize += common.StorageSize(len(blob))
|
||||
|
|
@ -205,7 +205,7 @@ func (t *traverser) live(owner common.Hash, hash common.Hash, path []byte, unref
|
|||
key = makeNodeKey(owner, t.state.hash)
|
||||
}
|
||||
// Replace the node in the traverser with the expanded one
|
||||
if enc, err := t.db.cleans.Get(key); err == nil && enc != nil {
|
||||
if enc, err := t.db.cleans.Get(string(t.state.hash[:])); err == nil && enc != nil {
|
||||
t.state.node = mustDecodeNode(t.state.hash[:], enc, 0)
|
||||
} else if node := t.db.dirties[key]; node != nil {
|
||||
t.state.node = node.node
|
||||
|
|
@ -217,6 +217,7 @@ func (t *traverser) live(owner common.Hash, hash common.Hash, path []byte, unref
|
|||
//panic(fmt.Sprintf("missing referenced node %x (searching for %x:%x at %x%x)", key, owner, t.state.hash, t.state.prefix, path))
|
||||
}
|
||||
t.state.node = mustDecodeNode(t.state.hash[:], blob, 0)
|
||||
t.db.cleans.Set(string(t.state.hash[:]), blob)
|
||||
}
|
||||
}
|
||||
// If we reached an account node, extract the storage trie root to continue on
|
||||
|
|
|
|||
Loading…
Reference in a new issue