Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 3,120 Lines • ▼ Show 20 Lines | if (pindex_was_in_chain) { | ||||
uiInterface.NotifyBlockTip(IsInitialBlockDownload(), | uiInterface.NotifyBlockTip(IsInitialBlockDownload(), | ||||
to_mark_failed_or_parked->pprev); | to_mark_failed_or_parked->pprev); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool FinalizeBlockAndInvalidate(const Config &config, CValidationState &state, | bool FinalizeBlockAndInvalidate(const Config &config, CValidationState &state, | ||||
CBlockIndex *pindex) { | CBlockIndex *pindex) { | ||||
AssertLockHeld(cs_main); | { | ||||
LOCK(cs_main); | |||||
if (!FinalizeBlockInternal(config, state, pindex)) { | if (!FinalizeBlockInternal(config, state, pindex)) { | ||||
// state is set by FinalizeBlockInternal. | // state is set by FinalizeBlockInternal. | ||||
return false; | return false; | ||||
} | } | ||||
// We have a valid candidate, make sure it is not parked. | // We have a valid candidate, make sure it is not parked. | ||||
if (pindex->nStatus.isOnParkedChain()) { | if (pindex->nStatus.isOnParkedChain()) { | ||||
UnparkBlock(pindex); | UnparkBlock(pindex); | ||||
} | } | ||||
} | |||||
// If the finalized block is not on the active chain, we need to rewind. | // If the finalized block is not on the active chain, we need to rewind. | ||||
if (!AreOnTheSameFork(pindex, chainActive.Tip())) { | if (AreOnTheSameFork(pindex, chainActive.Tip())) { | ||||
return true; | |||||
} | |||||
const CBlockIndex *pindexFork = chainActive.FindFork(pindex); | const CBlockIndex *pindexFork = chainActive.FindFork(pindex); | ||||
CBlockIndex *pindexToInvalidate = | CBlockIndex *pindexToInvalidate = | ||||
chainActive.Tip()->GetAncestor(pindexFork->nHeight + 1); | chainActive.Tip()->GetAncestor(pindexFork->nHeight + 1); | ||||
return InvalidateBlock(config, state, pindexToInvalidate); | |||||
} | |||||
return true; | return InvalidateBlock(config, state, pindexToInvalidate); | ||||
} | } | ||||
bool InvalidateBlock(const Config &config, CValidationState &state, | bool InvalidateBlock(const Config &config, CValidationState &state, | ||||
CBlockIndex *pindex) { | CBlockIndex *pindex) { | ||||
return g_chainstate.UnwindBlock(config, state, pindex, true); | return g_chainstate.UnwindBlock(config, state, pindex, true); | ||||
} | } | ||||
bool ParkBlock(const Config &config, CValidationState &state, | bool ParkBlock(const Config &config, CValidationState &state, | ||||
▲ Show 20 Lines • Show All 2,532 Lines • Show Last 20 Lines |