mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
core/rawdb: add truncateTailNoHeads
This commit is contained in:
parent
b22bb9869c
commit
4c23e7473d
1 changed files with 25 additions and 0 deletions
|
|
@ -301,6 +301,31 @@ func (f *Freezer) TruncateHead(items uint64) (uint64, error) {
|
|||
return oitems, nil
|
||||
}
|
||||
|
||||
// TruncateTailNoHeads discards any recent data below the provided threshold number.
|
||||
// Does not truncate the header and hash table
|
||||
func (f *Freezer) TruncateTailNoHeads(tail uint64) (uint64, error) {
|
||||
if f.readonly {
|
||||
return 0, errReadOnly
|
||||
}
|
||||
f.writeLock.Lock()
|
||||
defer f.writeLock.Unlock()
|
||||
|
||||
old := f.tail.Load()
|
||||
if old >= tail {
|
||||
return old, nil
|
||||
}
|
||||
for kind, table := range f.tables {
|
||||
if kind == ChainFreezerHeaderTable || kind == ChainFreezerHashTable {
|
||||
continue
|
||||
}
|
||||
if err := table.truncateTail(tail); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
f.tail.Store(tail)
|
||||
return old, nil
|
||||
}
|
||||
|
||||
// TruncateTail discards any recent data below the provided threshold number.
|
||||
func (f *Freezer) TruncateTail(tail uint64) (uint64, error) {
|
||||
if f.readonly {
|
||||
|
|
|
|||
Loading…
Reference in a new issue