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 @@ -94,7 +94,9 @@ namespace {
94
94
};
95
95
96
96
CBlockIndex *pindexBestInvalid;
97
- // may contain all CBlockIndex*'s that have validness >=BLOCK_VALID_TRANSACTIONS, and must contain those who aren't failed
97
+
98
+ // The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS or better that are at least
99
+ // as good as our current tip. Entries may be failed, though.
98
100
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid;
99
101
100
102
CCriticalSection cs_LastBlockFile;
@@ -2129,6 +2131,15 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
2129
2131
return false ;
2130
2132
}
2131
2133
} else {
2134
+ // Delete all entries in setBlockIndexValid that are worse than our new current block.
2135
+ // Note that we can't delete the current block itself, as we may need to return to it later in case a
2136
+ // reorganization to a better block fails.
2137
+ std::set<CBlockIndex*, CBlockIndexWorkComparator>::iterator it = setBlockIndexValid.begin ();
2138
+ while (setBlockIndexValid.value_comp ()(*it, chainActive.Tip ())) {
2139
+ setBlockIndexValid.erase (it++);
2140
+ }
2141
+ // Either the current tip or a successor of it we're working towards is left in setBlockIndexValid.
2142
+ assert (!setBlockIndexValid.empty ());
2132
2143
if (!pindexOldTip || chainActive.Tip ()->nChainWork > pindexOldTip->nChainWork ) {
2133
2144
// We're in a better position than we were. Return temporarily to release the lock.
2134
2145
break ;
You can’t perform that action at this time.
0 commit comments