Only remove actualy failed blocks from setBlockIndexValid

This commit is contained in:
Pieter Wuille 2014-07-09 17:42:50 +02:00
parent 52a7d52ffb
commit 5734d4d1e6
1 changed files with 2 additions and 1 deletions

View File

@ -2073,7 +2073,7 @@ static CBlockIndex* FindMostWorkChain() {
CBlockIndex *pindexTest = pindexNew;
bool fInvalidAncestor = false;
while (pindexTest && !chainActive.Contains(pindexTest)) {
if (!pindexTest->IsValid(BLOCK_VALID_TRANSACTIONS) || !(pindexTest->nStatus & BLOCK_HAVE_DATA)) {
if (pindexTest->nStatus & BLOCK_FAILED_MASK) {
// Candidate has an invalid ancestor, remove entire chain from the set.
if (pindexBestInvalid == NULL || pindexNew->nChainWork > pindexBestInvalid->nChainWork)
pindexBestInvalid = pindexNew;
@ -2083,6 +2083,7 @@ static CBlockIndex* FindMostWorkChain() {
setBlockIndexValid.erase(pindexFailed);
pindexFailed = pindexFailed->pprev;
}
setBlockIndexValid.erase(pindexTest);
fInvalidAncestor = true;
break;
}