mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Only keep setBlockIndexValid entries that are possible improvements
This commit is contained in:
parent
f3330b40a5
commit
714a3e6505
13
src/main.cpp
13
src/main.cpp
@ -94,7 +94,9 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CBlockIndex *pindexBestInvalid;
|
CBlockIndex *pindexBestInvalid;
|
||||||
// may contain all CBlockIndex*'s that have validness >=BLOCK_VALID_TRANSACTIONS, and must contain those who aren't failed
|
|
||||||
|
// The set of all CBlockIndex entries with BLOCK_VALID_TRANSACTIONS or better that are at least
|
||||||
|
// as good as our current tip. Entries may be failed, though.
|
||||||
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid;
|
set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid;
|
||||||
|
|
||||||
CCriticalSection cs_LastBlockFile;
|
CCriticalSection cs_LastBlockFile;
|
||||||
@ -2129,6 +2131,15 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Delete all entries in setBlockIndexValid that are worse than our new current block.
|
||||||
|
// Note that we can't delete the current block itself, as we may need to return to it later in case a
|
||||||
|
// reorganization to a better block fails.
|
||||||
|
std::set<CBlockIndex*, CBlockIndexWorkComparator>::iterator it = setBlockIndexValid.begin();
|
||||||
|
while (setBlockIndexValid.value_comp()(*it, chainActive.Tip())) {
|
||||||
|
setBlockIndexValid.erase(it++);
|
||||||
|
}
|
||||||
|
// Either the current tip or a successor of it we're working towards is left in setBlockIndexValid.
|
||||||
|
assert(!setBlockIndexValid.empty());
|
||||||
if (!pindexOldTip || chainActive.Tip()->nChainWork > pindexOldTip->nChainWork) {
|
if (!pindexOldTip || chainActive.Tip()->nChainWork > pindexOldTip->nChainWork) {
|
||||||
// We're in a better position than we were. Return temporarily to release the lock.
|
// We're in a better position than we were. Return temporarily to release the lock.
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user