forked from cerc-io/plugeth
downloader: fix edgecase where returned index is OOB for downloader (#18335)
* downloader: fix edgecase where returned index is OOB for downloader * downloader: documentation Co-Authored-By: holiman <martin@swende.se>
This commit is contained in:
parent
fe86a707d8
commit
5f251a6448
@ -1488,7 +1488,15 @@ func (d *Downloader) importBlockResults(results []*fetchResult) error {
|
|||||||
blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.Transactions, result.Uncles)
|
blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.Transactions, result.Uncles)
|
||||||
}
|
}
|
||||||
if index, err := d.blockchain.InsertChain(blocks); err != nil {
|
if index, err := d.blockchain.InsertChain(blocks); err != nil {
|
||||||
|
if index < len(results) {
|
||||||
log.Debug("Downloaded item processing failed", "number", results[index].Header.Number, "hash", results[index].Header.Hash(), "err", err)
|
log.Debug("Downloaded item processing failed", "number", results[index].Header.Number, "hash", results[index].Header.Hash(), "err", err)
|
||||||
|
} else {
|
||||||
|
// The InsertChain method in blockchain.go will sometimes return an out-of-bounds index,
|
||||||
|
// when it needs to preprocess blocks to import a sidechain.
|
||||||
|
// The importer will put together a new list of blocks to import, which is a superset
|
||||||
|
// of the blocks delivered from the downloader, and the indexing will be off.
|
||||||
|
log.Debug("Downloaded item processing failed on sidechain import", "index", index, "err", err)
|
||||||
|
}
|
||||||
return errInvalidChain
|
return errInvalidChain
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user