fix nil point in downloader (#409)

This commit is contained in:
zjubfd 2021-09-06 10:37:16 +08:00 committed by GitHub
parent 2d2740e2a2
commit 1540ad932d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -985,6 +985,10 @@ func (d *Downloader) findAncestorBinarySearch(p *peerConnection, mode SyncMode,
break
}
header := d.lightchain.GetHeaderByHash(h) // Independent of sync mode, header surely exists
if header == nil {
p.log.Error("header not found", "number", header.Number, "hash", header.Hash(), "request", check)
return 0, fmt.Errorf("%w: header no found (%d)", errBadPeer, header.Number)
}
if header.Number.Uint64() != check {
p.log.Warn("Received non requested header", "number", header.Number, "hash", header.Hash(), "request", check)
return 0, fmt.Errorf("%w: non-requested header (%d)", errBadPeer, header.Number)