diff --git a/trie/database.go b/trie/database.go index dee9f7844b..5b673938f0 100644 --- a/trie/database.go +++ b/trie/database.go @@ -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) { diff --git a/trie/hasher.go b/trie/hasher.go index 54f6a9de2b..649705ada8 100644 --- a/trie/hasher.go +++ b/trie/hasher.go @@ -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