mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
core/rawdb: fix size counting in memory freezer (#33344)
This commit is contained in:
parent
13a8798fa3
commit
b98b255449
1 changed files with 14 additions and 0 deletions
|
|
@ -91,6 +91,13 @@ func (t *memoryTable) truncateHead(items uint64) error {
|
|||
if items < t.offset {
|
||||
return errors.New("truncation below tail")
|
||||
}
|
||||
for i := int(items - t.offset); i < len(t.data); i++ {
|
||||
if t.size > uint64(len(t.data[i])) {
|
||||
t.size -= uint64(len(t.data[i]))
|
||||
} else {
|
||||
t.size = 0
|
||||
}
|
||||
}
|
||||
t.data = t.data[:items-t.offset]
|
||||
t.items = items
|
||||
return nil
|
||||
|
|
@ -108,6 +115,13 @@ func (t *memoryTable) truncateTail(items uint64) error {
|
|||
if t.items < items {
|
||||
return errors.New("truncation above head")
|
||||
}
|
||||
for i := uint64(0); i < items-t.offset; i++ {
|
||||
if t.size > uint64(len(t.data[i])) {
|
||||
t.size -= uint64(len(t.data[i]))
|
||||
} else {
|
||||
t.size = 0
|
||||
}
|
||||
}
|
||||
t.data = t.data[items-t.offset:]
|
||||
t.offset = items
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue