Skip to content

Commit

Permalink
fix: fix state inspect error after pruned state (#2557)
Browse files Browse the repository at this point in the history
  • Loading branch information
flywukong authored Jul 4, 2024
1 parent 971c0fa commit a5810fe
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/rawdb/ancient_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package rawdb

import (
"fmt"
"io"
"os"
"path/filepath"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -98,6 +100,18 @@ func inspectFreezers(db ethdb.Database) ([]freezerInfo, error) {
if err != nil {
return nil, err
}

file, err := os.Open(filepath.Join(datadir, StateFreezerName))
if err != nil {
return nil, err
}
defer file.Close()
// if state freezer folder has been pruned, there is no need for inspection
_, err = file.Readdirnames(1)
if err == io.EOF {
continue
}

f, err := NewStateFreezer(datadir, true, 0)
if err != nil {
return nil, err
Expand Down

0 comments on commit a5810fe

Please sign in to comment.