mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/utils: report the blocknumber when block import fails (#27213)
When block import fails, the error displays the number of the first block past the import batch, not the number of the failing block. This change fixes this problem by identifying which blocks fails and reporting its number.
This commit is contained in:
parent
182fc72b0e
commit
f9652a36d9
1 changed files with 8 additions and 2 deletions
|
|
@ -211,8 +211,14 @@ func ImportChain(chain *core.BlockChain, fn string) error {
|
|||
log.Info("Skipping batch as all blocks present", "batch", batch, "first", blocks[0].Hash(), "last", blocks[i-1].Hash())
|
||||
continue
|
||||
}
|
||||
if _, err := chain.InsertChain(missing); err != nil {
|
||||
return fmt.Errorf("invalid block %d: %v", n, err)
|
||||
if failindex, err := chain.InsertChain(missing); err != nil {
|
||||
var failnumber uint64
|
||||
if failindex > 0 && failindex < len(missing) {
|
||||
failnumber = missing[failindex].NumberU64()
|
||||
} else {
|
||||
failnumber = missing[0].NumberU64()
|
||||
}
|
||||
return fmt.Errorf("invalid block %d: %v", failnumber, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue