trie: make db insert use size instead of full data

This commit is contained in:
Martin Holst Swende 2019-12-26 11:08:36 +01:00
parent 0b047fcbd2
commit d24bd3d9ed
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
2 changed files with 6 additions and 6 deletions

View file

@ -314,24 +314,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,
}
for _, child := range entry.childs() {

View file

@ -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