Skip to content

Commit 6ee1ff1

Browse files
rjl493456442zzyalbert
authored andcommitted
ethdb: more accurate batch size calculation (ethereum#23790)
This PR also counts the size of the key when calculating the size of a db batch
1 parent 80f569f commit 6ee1ff1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ethdb/leveldb/leveldb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ type batch struct {
455455
// Put inserts the given value into the batch for later committing.
456456
func (b *batch) Put(key, value []byte) error {
457457
b.b.Put(key, value)
458-
b.size += len(value)
458+
b.size += len(key) + len(value)
459459
return nil
460460
}
461461

ethdb/memorydb/memorydb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ type batch struct {
204204
// Put inserts the given value into the batch for later committing.
205205
func (b *batch) Put(key, value []byte) error {
206206
b.writes = append(b.writes, keyvalue{common.CopyBytes(key), common.CopyBytes(value), false})
207-
b.size += len(value)
207+
b.size += len(key) + len(value)
208208
return nil
209209
}
210210

0 commit comments

Comments
 (0)