Skip to content

Commit

Permalink
fix: change some code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjunLi committed Jul 16, 2024
1 parent b374f90 commit 6436146
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions core/rawdb/prunedfreezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ 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 {
Expand Down Expand Up @@ -100,16 +99,19 @@ func (f *prunedfreezer) repair(datadir string) error {
// 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.
var offset uint64
if minItems != 0 {
offset = minItems
} else {
offset = atomic.LoadUint64(&f.frozen)
}
log.Info("Read ancientdb item counts", "items", minItems, "offset", offset)

if frozen := ReadFrozenOfAncientFreezer(f.db); frozen > offset {
offset = frozen
}
// FrozenOfAncientFreezer is the progress of the last prune-freezer freeze.
frozenInDB := ReadFrozenOfAncientFreezer(f.db)
maxOffset := max(offset, frozenInDB)

atomic.StoreUint64(&f.frozen, offset)
atomic.StoreUint64(&f.frozen, maxOffset)
if err := f.Sync(); err != nil {
return nil
}
Expand Down

0 comments on commit 6436146

Please sign in to comment.