Skip to content

Commit

Permalink
core/rawdb: check gap ascending
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Feb 17, 2023
1 parent 71e6727 commit ebe1bd2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/rawdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ func NewDatabaseWithFreezer(db ethdb.KeyValueStore, ancient string, namespace st
// Find the smallest block stored in the key-value store
// in range of [frozen, head]
var number uint64
for number = head; number >= frozen; number -= 1 {
data, _ := db.Get(headerHashKey(number))
if len(data) == 0 {
for number = frozen; number <= head; number++ {
if present, _ := db.Has(headerHashKey(number)); present {
break
}
}
// We are about to exit on error. Print database metdata beore exiting
PrintChainMetadata(db)
return nil, fmt.Errorf("gap in the chain between ancients (#%d) and leveldb (#%d) ", frozen, number)
return nil, fmt.Errorf("gap in the chain between ancients [0 - #%d] and leveldb [#%d - #%d] ",
frozen-1, number, head)
}
// Database contains only older data than the freezer, this happens if the
// state was wiped and reinited from an existing freezer.
Expand Down

0 comments on commit ebe1bd2

Please sign in to comment.