Skip to content

Commit 70d0325

Browse files
committed
Merge pull request #4496
5734d4d Only remove actualy failed blocks from setBlockIndexValid (Pieter Wuille)
2 parents 7eb3d61 + 5734d4d commit 70d0325

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ static CBlockIndex* FindMostWorkChain() {
20162016
CBlockIndex *pindexTest = pindexNew;
20172017
bool fInvalidAncestor = false;
20182018
while (pindexTest && !chainActive.Contains(pindexTest)) {
2019-
if (!pindexTest->IsValid(BLOCK_VALID_TRANSACTIONS) || !(pindexTest->nStatus & BLOCK_HAVE_DATA)) {
2019+
if (pindexTest->nStatus & BLOCK_FAILED_MASK) {
20202020
// Candidate has an invalid ancestor, remove entire chain from the set.
20212021
if (pindexBestInvalid == NULL || pindexNew->nChainWork > pindexBestInvalid->nChainWork)
20222022
pindexBestInvalid = pindexNew;
@@ -2026,6 +2026,7 @@ static CBlockIndex* FindMostWorkChain() {
20262026
setBlockIndexValid.erase(pindexFailed);
20272027
pindexFailed = pindexFailed->pprev;
20282028
}
2029+
setBlockIndexValid.erase(pindexTest);
20292030
fInvalidAncestor = true;
20302031
break;
20312032
}

0 commit comments

Comments
 (0)