From 217b64ed6ecc5fafa59335df787b97cf439fedac Mon Sep 17 00:00:00 2001 From: Chris Li <271678682li@gmail.com> Date: Tue, 20 Aug 2024 16:50:02 +0800 Subject: [PATCH] fix: fix minItems --- core/rawdb/prunedfreezer.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/core/rawdb/prunedfreezer.go b/core/rawdb/prunedfreezer.go index b9c18ac2aa..bb33c937f4 100644 --- a/core/rawdb/prunedfreezer.go +++ b/core/rawdb/prunedfreezer.go @@ -68,6 +68,7 @@ func newPrunedFreezer(datadir string, db ethdb.KeyValueStore, offset uint64) (*p // repair init frozen , compatible disk-ancientdb and pruner-block-tool. func (f *prunedfreezer) repair(datadir string) error { + offset := atomic.LoadUint64(&f.frozen) // compatible freezer minItems := uint64(math.MaxUint64) for name, disableSnappy := range chainFreezerNoSnappy { @@ -96,14 +97,8 @@ func (f *prunedfreezer) repair(datadir string) error { table.Close() } - // If minItems is non-zero, it indicates that the chain freezer was previously enabled, and we should use minItems as the current frozen value. - // If minItems is zero, it indicates that the pruneAncient was previously enabled, and we should continue using frozen - // (retrieved from CurrentAncientFreezer) as the current frozen value. - offset := minItems - if offset == 0 { - // no item in ancientDB, init `offset` to the `f.frozen` - offset = atomic.LoadUint64(&f.frozen) - } + // minItems is the value relative to offset + offset += minItems log.Info("Read ancientdb item counts", "items", minItems, "offset", offset) // FrozenOfAncientFreezer is the progress of the last prune-freezer freeze.