mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-08 17:21:47 +00:00
ethdb: more accurate batch size calculation (#23790)
This PR also counts the size of the key when calculating the size of a db batch
This commit is contained in:
parent
c72b16c340
commit
53f81574e3
2 changed files with 2 additions and 2 deletions
|
|
@ -455,7 +455,7 @@ type batch struct {
|
||||||
// Put inserts the given value into the batch for later committing.
|
// Put inserts the given value into the batch for later committing.
|
||||||
func (b *batch) Put(key, value []byte) error {
|
func (b *batch) Put(key, value []byte) error {
|
||||||
b.b.Put(key, value)
|
b.b.Put(key, value)
|
||||||
b.size += len(value)
|
b.size += len(key) + len(value)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ type batch struct {
|
||||||
// Put inserts the given value into the batch for later committing.
|
// Put inserts the given value into the batch for later committing.
|
||||||
func (b *batch) Put(key, value []byte) error {
|
func (b *batch) Put(key, value []byte) error {
|
||||||
b.writes = append(b.writes, keyvalue{common.CopyBytes(key), common.CopyBytes(value), false})
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue