Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 3,173 Lines • ▼ Show 20 Lines | bool ParkBlock(const Config &config, CValidationState &state, | ||||
return g_chainstate.UnwindBlock(config, state, pindex, false); | return g_chainstate.UnwindBlock(config, state, pindex, false); | ||||
} | } | ||||
template <typename F> | template <typename F> | ||||
void CChainState::UpdateFlagsForBlock(CBlockIndex *pindexBase, | void CChainState::UpdateFlagsForBlock(CBlockIndex *pindexBase, | ||||
CBlockIndex *pindex, F f) { | CBlockIndex *pindex, F f) { | ||||
BlockStatus newStatus = f(pindex->nStatus); | BlockStatus newStatus = f(pindex->nStatus); | ||||
if (pindex->nStatus != newStatus && | if (pindex->nStatus != newStatus && | ||||
pindex->GetAncestor(pindexBase->nHeight) == pindexBase) { | (!pindexBase || | ||||
pindex->GetAncestor(pindexBase->nHeight) == pindexBase)) { | |||||
pindex->nStatus = newStatus; | pindex->nStatus = newStatus; | ||||
setDirtyBlockIndex.insert(pindex); | setDirtyBlockIndex.insert(pindex); | ||||
if (newStatus.isValid()) { | if (newStatus.isValid()) { | ||||
m_failed_blocks.erase(pindex); | m_failed_blocks.erase(pindex); | ||||
} | } | ||||
if (pindex->IsValid(BlockValidity::TRANSACTIONS) && | if (pindex->IsValid(BlockValidity::TRANSACTIONS) && | ||||
pindex->HaveTxsDownloaded() && | pindex->HaveTxsDownloaded() && | ||||
Show All 14 Lines | void CChainState::UpdateFlags(CBlockIndex *pindex, F f, C fchild) { | ||||
BlockMap::iterator it = mapBlockIndex.begin(); | BlockMap::iterator it = mapBlockIndex.begin(); | ||||
while (it != mapBlockIndex.end()) { | while (it != mapBlockIndex.end()) { | ||||
UpdateFlagsForBlock(pindex, it->second, fchild); | UpdateFlagsForBlock(pindex, it->second, fchild); | ||||
it++; | it++; | ||||
} | } | ||||
// Update the flags from all ancestors too. | // Update the flags from all ancestors too. | ||||
while (pindex != nullptr) { | while (pindex != nullptr) { | ||||
BlockStatus newStatus = f(pindex->nStatus); | UpdateFlagsForBlock(nullptr, pindex, f); | ||||
if (pindex->nStatus != newStatus) { | |||||
pindex->nStatus = newStatus; | |||||
setDirtyBlockIndex.insert(pindex); | |||||
if (newStatus.isValid()) { | |||||
m_failed_blocks.erase(pindex); | |||||
} | |||||
} | |||||
pindex = pindex->pprev; | pindex = pindex->pprev; | ||||
} | } | ||||
} | } | ||||
template <typename F> void CChainState::UpdateFlags(CBlockIndex *pindex, F f) { | template <typename F> void CChainState::UpdateFlags(CBlockIndex *pindex, F f) { | ||||
// Handy shorthand. | // Handy shorthand. | ||||
UpdateFlags(pindex, f, f); | UpdateFlags(pindex, f, f); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,612 Lines • Show Last 20 Lines |