File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,9 @@ namespace {
95
95
};
96
96
97
97
CBlockIndex *pindexBestInvalid;
98
- // may contain all CBlockIndex*'s that have validness >=BLOCK_VALID_TRANSACTIONS, and must contain those who aren't failed
98
+
99
+ // The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS or better that are at least
100
+ // as good as our current tip. Entries may be failed, though.
99
101
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid;
100
102
101
103
CCriticalSection cs_LastBlockFile;
@@ -2097,6 +2099,15 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
2097
2099
return false ;
2098
2100
}
2099
2101
} else {
2102
+ // Delete all entries in setBlockIndexValid that are worse than our new current block.
2103
+ // Note that we can't delete the current block itself, as we may need to return to it later in case a
2104
+ // reorganization to a better block fails.
2105
+ std::set<CBlockIndex*, CBlockIndexWorkComparator>::iterator it = setBlockIndexValid.begin ();
2106
+ while (setBlockIndexValid.value_comp ()(*it, chainActive.Tip ())) {
2107
+ setBlockIndexValid.erase (it++);
2108
+ }
2109
+ // Either the current tip or a successor of it we're working towards is left in setBlockIndexValid.
2110
+ assert (!setBlockIndexValid.empty ());
2100
2111
if (!pindexOldTip || chainActive.Tip ()->nChainWork > pindexOldTip->nChainWork ) {
2101
2112
// We're in a better position than we were. Return temporarily to release the lock.
2102
2113
break ;
You can’t perform that action at this time.
0 commit comments