From d9e3ce8aed4683de6708c8ad43b1ffa6f17ec96a Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 14 Mar 2025 12:58:35 +0100 Subject: [PATCH] core/rawdb: update comment --- core/rawdb/freezer.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/rawdb/freezer.go b/core/rawdb/freezer.go index 57c9afc3da..dc623ca123 100644 --- a/core/rawdb/freezer.go +++ b/core/rawdb/freezer.go @@ -301,9 +301,10 @@ func (f *Freezer) TruncateHead(items uint64) (uint64, error) { return oitems, nil } -// TruncateTailBlocks discards any recent data below the provided threshold number. -// Only truncates blocks and receipts. -func (f *Freezer) TruncateTailBlocks(tail uint64) (uint64, error) { +// TruncateTailBlocks discards all data below the provided threshold block number. +// This is intended to be used with the chain freezer. Unlike TruncateTail, it +// only truncates blocks and receipts, leaving the header table where it is. +func (f *Freezer) TruncateTailBlocks(tailBlock uint64) (uint64, error) { if f.readonly { return 0, errReadOnly } @@ -311,21 +312,21 @@ func (f *Freezer) TruncateTailBlocks(tail uint64) (uint64, error) { defer f.writeLock.Unlock() old := f.tail.Load() - if old >= tail { + if old >= tailBlock { return old, nil } for kind, table := range f.tables { if kind == ChainFreezerBodiesTable || kind == ChainFreezerReceiptTable { - if err := table.truncateTail(tail); err != nil { + if err := table.truncateTail(tailBlock); err != nil { return 0, err } } } - f.tail.Store(tail) + f.tail.Store(tailBlock) return old, nil } -// TruncateTail discards any recent data below the provided threshold number. +// TruncateTail discards all data below the provided threshold number. func (f *Freezer) TruncateTail(tail uint64) (uint64, error) { if f.readonly { return 0, errReadOnly