Skip to content

Commit

Permalink
ethdb: more accurate batch size calculation (#23790)
Browse files Browse the repository at this point in the history
This PR also counts the size of the key when calculating the size of a db batch
  • Loading branch information
rjl493456442 authored Oct 26, 2021
1 parent c72b16c commit 53f8157
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ethdb/leveldb/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ type batch struct {
// Put inserts the given value into the batch for later committing.
func (b *batch) Put(key, value []byte) error {
b.b.Put(key, value)
b.size += len(value)
b.size += len(key) + len(value)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion ethdb/memorydb/memorydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ type batch struct {
// Put inserts the given value into the batch for later committing.
func (b *batch) Put(key, value []byte) error {
b.writes = append(b.writes, keyvalue{common.CopyBytes(key), common.CopyBytes(value), false})
b.size += len(value)
b.size += len(key) + len(value)
return nil
}

Expand Down

0 comments on commit 53f8157

Please sign in to comment.