Skip to content

Commit

Permalink
flags: fix some lint issues;
Browse files Browse the repository at this point in the history
  • Loading branch information
galaio committed Dec 27, 2024
1 parent de1a618 commit 49b0981
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 64 deletions.
1 change: 1 addition & 0 deletions core/rawdb/chain_freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ func (f *chainFreezer) tryPruneHistoryBlock(best uint64) {
ancientHead, err := f.Ancients()
if err != nil {
log.Warn("PruneHistoryBlock query Ancients error", "best", best, "err", err)
return
}
if expectTail > ancientHead {
expectTail = ancientHead
Expand Down
47 changes: 1 addition & 46 deletions core/rawdb/freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ import (
"path/filepath"
"sync"
"sync/atomic"
"time"

"golang.org/x/exp/slices"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
Expand Down Expand Up @@ -500,49 +498,6 @@ func (f *Freezer) repair() error {
return nil
}

// delete leveldb data that save to ancientdb, split from func freeze
func gcKvStore(db ethdb.KeyValueStore, ancients []common.Hash, first uint64, frozen uint64, start time.Time) {
// Wipe out all data from the active database
batch := db.NewBatch()
for i := 0; i < len(ancients); i++ {
// Always keep the genesis block in active database
if blockNumber := first + uint64(i); blockNumber != 0 {
DeleteBlockWithoutNumber(batch, ancients[i], blockNumber)
DeleteCanonicalHash(batch, blockNumber)
}
}
if err := batch.Write(); err != nil {
log.Crit("Failed to delete frozen canonical blocks", "err", err)
}
batch.Reset()

// Wipe out side chains also and track dangling side chians
var dangling []common.Hash
for number := first; number < frozen; number++ {
// Always keep the genesis block in active database
if number != 0 {
dangling = ReadAllHashes(db, number)
for _, hash := range dangling {
log.Trace("Deleting side chain", "number", number, "hash", hash)
DeleteBlock(batch, hash, number)
}
}
}
if err := batch.Write(); err != nil {
log.Crit("Failed to delete frozen side blocks", "err", err)
}
batch.Reset()

// Log something friendly for the user
context := []interface{}{
"blocks", frozen - first, "elapsed", common.PrettyDuration(time.Since(start)), "number", frozen - 1,
}
if n := len(ancients); n > 0 {
context = append(context, []interface{}{"hash", ancients[n-1]}...)
}
log.Info("Deep froze chain segment", context...)
}

// TruncateTableTail will truncate certain table to new tail
func (f *Freezer) TruncateTableTail(kind string, tail uint64) (uint64, error) {
if f.readonly {
Expand Down Expand Up @@ -609,7 +564,7 @@ func (f *Freezer) ResetTable(kind string, startAt uint64, onlyEmpty bool) error
}

// resetTailMeta will reset tail meta with legacyOffset
// Caution: the freezer cannot be used anymore, it will release all data files
// Caution: the freezer cannot be used anymore, it will sync/close all data files
func (f *Freezer) resetTailMeta(legacyOffset uint64) error {
if f.readonly {
return errReadOnly
Expand Down
2 changes: 1 addition & 1 deletion core/rawdb/freezer_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ func (t *freezerTable) resetItems(startAt uint64) (*freezerTable, error) {
}

// resetTailMeta reset freezer table with new legacyOffset
// Caution: the table cannot be used anymore, it will release all data files
// Caution: the table cannot be used anymore, it will sync/close all data files
func (t *freezerTable) resetTailMeta(legacyOffset uint64) error {
t.lock.Lock()
defer t.lock.Unlock()
Expand Down
17 changes: 0 additions & 17 deletions core/rawdb/schema_legacy.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
// Copyright 2018 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// Package rawdb contains a collection of low level database accessors.
package rawdb

import (
Expand Down

0 comments on commit 49b0981

Please sign in to comment.