When rewinding, reset pindexBestInvalid if it is pointing to a removed block

This commit is contained in:
Jack Grigg 2018-04-11 21:46:58 -06:00
parent 079d9e6a57
commit 39ee63c876
No known key found for this signature in database
GPG Key ID: 665DBCD284F7DAFF
1 changed files with 4 additions and 0 deletions

View File

@ -4058,6 +4058,10 @@ bool RewindBlockIndex(const CChainParams& params)
if (!sufficientlyValidated(pindexIter) && !chainActive.Contains(pindexIter)) {
// Add to the list of blocks to remove
vBlocks.push_back(pindexIter);
if (pindexIter == pindexBestInvalid) {
// Reset invalid block marker if it was pointing to this block
pindexBestInvalid = NULL;
}
// Update indices
setBlockIndexCandidates.erase(pindexIter);
auto ret = mapBlocksUnlinked.equal_range(pindexIter->pprev);