Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,735 Lines • ▼ Show 20 Lines | while (fContinue && nHeight != pindexMostWork->nHeight) { | ||||
fContinue = false; | fContinue = false; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (fBlocksDisconnected) { | if (fBlocksDisconnected) { | ||||
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, | mempool.removeForReorg(config, pcoinsTip, | ||||
chainActive.Tip()->nHeight + 1, | |||||
STANDARD_LOCKTIME_VERIFY_FLAGS); | STANDARD_LOCKTIME_VERIFY_FLAGS); | ||||
LimitMempoolSize( | LimitMempoolSize( | ||||
mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, | mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, | ||||
GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); | GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); | ||||
} | } | ||||
mempool.check(pcoinsTip); | mempool.check(pcoinsTip); | ||||
// Callbacks/notifications for a new best chain. | // Callbacks/notifications for a new best chain. | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | bool InvalidateBlock(const Config &config, CValidationState &state, | ||||
while (chainActive.Contains(pindex)) { | while (chainActive.Contains(pindex)) { | ||||
CBlockIndex *pindexWalk = chainActive.Tip(); | CBlockIndex *pindexWalk = chainActive.Tip(); | ||||
pindexWalk->nStatus |= BLOCK_FAILED_CHILD; | pindexWalk->nStatus |= BLOCK_FAILED_CHILD; | ||||
setDirtyBlockIndex.insert(pindexWalk); | setDirtyBlockIndex.insert(pindexWalk); | ||||
setBlockIndexCandidates.erase(pindexWalk); | setBlockIndexCandidates.erase(pindexWalk); | ||||
// 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)) { | if (!DisconnectTip(config, state)) { | ||||
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, | mempool.removeForReorg(config, pcoinsTip, | ||||
chainActive.Tip()->nHeight + 1, | |||||
STANDARD_LOCKTIME_VERIFY_FLAGS); | STANDARD_LOCKTIME_VERIFY_FLAGS); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
LimitMempoolSize( | LimitMempoolSize( | ||||
mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, | mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, | ||||
GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); | GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); | ||||
// The resulting new best tip may not be in setBlockIndexCandidates anymore, | // The resulting new best tip may not be in setBlockIndexCandidates anymore, | ||||
// so add it again. | // so add it again. | ||||
BlockMap::iterator it = mapBlockIndex.begin(); | BlockMap::iterator it = mapBlockIndex.begin(); | ||||
while (it != mapBlockIndex.end()) { | while (it != mapBlockIndex.end()) { | ||||
if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && | if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && | ||||
it->second->nChainTx && | it->second->nChainTx && | ||||
!setBlockIndexCandidates.value_comp()(it->second, | !setBlockIndexCandidates.value_comp()(it->second, | ||||
chainActive.Tip())) { | chainActive.Tip())) { | ||||
setBlockIndexCandidates.insert(it->second); | setBlockIndexCandidates.insert(it->second); | ||||
} | } | ||||
it++; | it++; | ||||
} | } | ||||
InvalidChainFound(pindex); | InvalidChainFound(pindex); | ||||
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, | mempool.removeForReorg(config, pcoinsTip, chainActive.Tip()->nHeight + 1, | ||||
STANDARD_LOCKTIME_VERIFY_FLAGS); | STANDARD_LOCKTIME_VERIFY_FLAGS); | ||||
uiInterface.NotifyBlockTip(IsInitialBlockDownload(), pindex->pprev); | uiInterface.NotifyBlockTip(IsInitialBlockDownload(), pindex->pprev); | ||||
return true; | return true; | ||||
} | } | ||||
bool ResetBlockFailureFlags(CBlockIndex *pindex) { | bool ResetBlockFailureFlags(CBlockIndex *pindex) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
▲ Show 20 Lines • Show All 2,107 Lines • Show Last 20 Lines |