Skip to content

Commit a3267ed

Browse files
committed
trie: don't report the root flushlist as an alloc
1 parent 9f7592c commit a3267ed

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎trie/database.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func (db *Database) Cap(limit common.StorageSize) error {
297297
// db.nodesSize only contains the useful data in the cache, but when reporting
298298
// the total memory consumption, the maintenance metadata is also needed to be
299299
// counted. For every useful node, we track 2 extra hashes as the flushlist.
300-
size := db.nodesSize + common.StorageSize(len(db.nodes)*2*common.HashLength)
300+
size := db.nodesSize + common.StorageSize((len(db.nodes)-1)*2*common.HashLength)
301301

302302
// If the preimage cache got large enough, push to disk. If it's still small
303303
// leave for later to deduplicate writes.
@@ -512,6 +512,6 @@ func (db *Database) Size() (common.StorageSize, common.StorageSize) {
512512
// db.nodesSize only contains the useful data in the cache, but when reporting
513513
// the total memory consumption, the maintenance metadata is also needed to be
514514
// counted. For every useful node, we track 2 extra hashes as the flushlist.
515-
var flushlistSize = common.StorageSize(len(db.nodes) * 2 * common.HashLength)
515+
var flushlistSize = common.StorageSize((len(db.nodes) - 1) * 2 * common.HashLength)
516516
return db.nodesSize + flushlistSize, db.preimagesSize
517517
}

0 commit comments

Comments
 (0)