mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
trie: make db insert use size instead of full data
This commit is contained in:
parent
a903912b96
commit
1ed51e97a3
2 changed files with 6 additions and 6 deletions
|
|
@ -310,24 +310,24 @@ func (db *Database) InsertBlob(hash common.Hash, blob []byte) {
|
|||
db.lock.Lock()
|
||||
defer db.lock.Unlock()
|
||||
|
||||
db.insert(hash, blob, rawNode(blob))
|
||||
db.insert(hash, len(blob), rawNode(blob))
|
||||
}
|
||||
|
||||
// insert inserts a collapsed trie node into the memory database. This method is
|
||||
// a more generic version of InsertBlob, supporting both raw blob insertions as
|
||||
// well ex trie node insertions. The blob must always be specified to allow proper
|
||||
// well ex trie node insertions. The blob size must be specified to allow proper
|
||||
// size tracking.
|
||||
func (db *Database) insert(hash common.Hash, blob []byte, node node) {
|
||||
func (db *Database) insert(hash common.Hash, size int, node node) {
|
||||
// If the node's already cached, skip
|
||||
if _, ok := db.dirties[hash]; ok {
|
||||
return
|
||||
}
|
||||
memcacheDirtyWriteMeter.Mark(int64(len(blob)))
|
||||
memcacheDirtyWriteMeter.Mark(int64(size))
|
||||
|
||||
// Create the cached entry for this node
|
||||
entry := &cachedNode{
|
||||
node: simplifyNode(node),
|
||||
size: uint16(len(blob)),
|
||||
size: uint16(size),
|
||||
flushPrev: db.newest,
|
||||
}
|
||||
entry.forChilds(func(child common.Hash) {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ func (h *hasher) store(n node, db *Database, force bool) (node, error) {
|
|||
hash := common.BytesToHash(hash)
|
||||
|
||||
db.lock.Lock()
|
||||
db.insert(hash, h.tmp, n)
|
||||
db.insert(hash, len(h.tmp), n)
|
||||
db.lock.Unlock()
|
||||
|
||||
// Track external references from account->storage trie
|
||||
|
|
|
|||
Loading…
Reference in a new issue