Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 410 Lines • ▼ Show 20 Lines | if (useExistingLockPoints) { | ||||
// except in the special case where the relative lock time/height is | // except in the special case where the relative lock time/height is | ||||
// 0, which is equivalent to no sequence lock. Since we assume input | // 0, which is equivalent to no sequence lock. Since we assume input | ||||
// height of tip+1 for mempool txs and test the resulting lockPair | // height of tip+1 for mempool txs and test the resulting lockPair | ||||
// from CalculateSequenceLocks against tip+1. We know | // from CalculateSequenceLocks against tip+1. We know | ||||
// EvaluateSequenceLocks will fail if there was a non-zero sequence | // EvaluateSequenceLocks will fail if there was a non-zero sequence | ||||
// lock on a mempool input, so we can use the return value of | // lock on a mempool input, so we can use the return value of | ||||
// CheckSequenceLocks to indicate the LockPoints validity. | // CheckSequenceLocks to indicate the LockPoints validity. | ||||
int maxInputHeight = 0; | int maxInputHeight = 0; | ||||
for (int height : prevheights) { | for (const int height : prevheights) { | ||||
// Can ignore mempool inputs since we'll fail if they had | // Can ignore mempool inputs since we'll fail if they had | ||||
// non-zero locks. | // non-zero locks. | ||||
if (height != tip->nHeight + 1) { | if (height != tip->nHeight + 1) { | ||||
maxInputHeight = std::max(maxInputHeight, height); | maxInputHeight = std::max(maxInputHeight, height); | ||||
} | } | ||||
} | } | ||||
lp->maxInputBlock = tip->GetAncestor(maxInputHeight); | lp->maxInputBlock = tip->GetAncestor(maxInputHeight); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 4,584 Lines • ▼ Show 20 Lines | void UnloadBlockIndex() { | ||||
pindexBestForkBase = nullptr; | pindexBestForkBase = nullptr; | ||||
g_mempool.clear(); | g_mempool.clear(); | ||||
mapBlocksUnlinked.clear(); | mapBlocksUnlinked.clear(); | ||||
vinfoBlockFile.clear(); | vinfoBlockFile.clear(); | ||||
nLastBlockFile = 0; | nLastBlockFile = 0; | ||||
setDirtyBlockIndex.clear(); | setDirtyBlockIndex.clear(); | ||||
setDirtyFileInfo.clear(); | setDirtyFileInfo.clear(); | ||||
for (BlockMap::value_type &entry : mapBlockIndex) { | for (const BlockMap::value_type &entry : mapBlockIndex) { | ||||
delete entry.second; | delete entry.second; | ||||
} | } | ||||
mapBlockIndex.clear(); | mapBlockIndex.clear(); | ||||
fHavePruned = false; | fHavePruned = false; | ||||
g_chainstate.UnloadBlockIndex(); | g_chainstate.UnloadBlockIndex(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | void CChainState::CheckBlockIndex(const Consensus::Params &consensusParams) { | ||||
// require that chainActive has been initialized.) | // require that chainActive has been initialized.) | ||||
if (chainActive.Height() < 0) { | if (chainActive.Height() < 0) { | ||||
assert(mapBlockIndex.size() <= 1); | assert(mapBlockIndex.size() <= 1); | ||||
return; | return; | ||||
} | } | ||||
// Build forward-pointing map of the entire block tree. | // Build forward-pointing map of the entire block tree. | ||||
std::multimap<CBlockIndex *, CBlockIndex *> forward; | std::multimap<CBlockIndex *, CBlockIndex *> forward; | ||||
for (auto &entry : mapBlockIndex) { | for (const auto &entry : mapBlockIndex) { | ||||
forward.emplace(entry.second->pprev, entry.second); | forward.emplace(entry.second->pprev, entry.second); | ||||
} | } | ||||
assert(forward.size() == mapBlockIndex.size()); | assert(forward.size() == mapBlockIndex.size()); | ||||
std::pair<std::multimap<CBlockIndex *, CBlockIndex *>::iterator, | std::pair<std::multimap<CBlockIndex *, CBlockIndex *>::iterator, | ||||
std::multimap<CBlockIndex *, CBlockIndex *>::iterator> | std::multimap<CBlockIndex *, CBlockIndex *>::iterator> | ||||
rangeGenesis = forward.equal_range(nullptr); | rangeGenesis = forward.equal_range(nullptr); | ||||
▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines |