Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,723 Lines • ▼ Show 20 Lines | bool PreciousBlock(const Config &config, CValidationState &state, | ||||
return ActivateBestChain(config, state); | return ActivateBestChain(config, state); | ||||
} | } | ||||
static bool UnwindBlock(const Config &config, CValidationState &state, | static bool UnwindBlock(const Config &config, CValidationState &state, | ||||
CBlockIndex *pindex, bool invalidate) { | CBlockIndex *pindex, bool invalidate) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
// Mark the block itself as invalid. | // Mark the block as either invalid or parked. | ||||
pindex->nStatus = | pindex->nStatus = invalidate ? pindex->nStatus.withFailed() | ||||
pindex->nStatus.withFailed(invalidate).withParked(!invalidate); | : pindex->nStatus.withParked(); | ||||
setDirtyBlockIndex.insert(pindex); | setDirtyBlockIndex.insert(pindex); | ||||
DisconnectedBlockTransactions disconnectpool; | DisconnectedBlockTransactions disconnectpool; | ||||
while (chainActive.Contains(pindex)) { | while (chainActive.Contains(pindex)) { | ||||
CBlockIndex *pindexWalk = chainActive.Tip(); | CBlockIndex *pindexWalk = chainActive.Tip(); | ||||
pindexWalk->nStatus = | pindexWalk->nStatus = invalidate ? pindex->nStatus.withFailedParent() | ||||
pindexWalk->nStatus.withFailed(invalidate).withParked(!invalidate); | : pindex->nStatus.withParkedParent(); | ||||
setDirtyBlockIndex.insert(pindexWalk); | setDirtyBlockIndex.insert(pindex); | ||||
// ActivateBestChain considers blocks already in chainActive | // ActivateBestChain considers blocks already in chainActive | ||||
// unconditionally valid already, so force disconnect away from it. | // unconditionally valid already, so force disconnect away from it. | ||||
if (!DisconnectTip(config, state, &disconnectpool)) { | if (!DisconnectTip(config, state, &disconnectpool)) { | ||||
// It's probably hopeless to try to make the mempool consistent | // It's probably hopeless to try to make the mempool consistent | ||||
// here if DisconnectTip failed, but we can try. | // here if DisconnectTip failed, but we can try. | ||||
disconnectpool.updateMempoolForReorg(config, false); | disconnectpool.updateMempoolForReorg(config, false); | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 2,498 Lines • Show Last 20 Lines |