MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / InvalidateBlock

Function InvalidateBlock

src/main.cpp:3048–3084  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3046}
3047
3048bool InvalidateBlock(CValidationState& state, CBlockIndex *pindex) {
3049 AssertLockHeld(cs_main);
3050
3051 // Mark the block itself as invalid.
3052 pindex->nStatus |= BLOCK_FAILED_VALID;
3053 setDirtyBlockIndex.insert(pindex);
3054 setBlockIndexCandidates.erase(pindex);
3055
3056 while (chainActive.Contains(pindex)) {
3057 CBlockIndex *pindexWalk = chainActive.Tip();
3058 pindexWalk->nStatus |= BLOCK_FAILED_CHILD;
3059 setDirtyBlockIndex.insert(pindexWalk);
3060 setBlockIndexCandidates.erase(pindexWalk);
3061 // ActivateBestChain considers blocks already in chainActive
3062 // unconditionally valid already, so force disconnect away from it.
3063 if (!DisconnectTip(state)) {
3064 mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
3065 return false;
3066 }
3067 }
3068
3069 mempool.TrimToSize(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
3070
3071 // The resulting new best tip may not be in setBlockIndexCandidates anymore, so
3072 // add it again.
3073 BlockMap::iterator it = mapBlockIndex.begin();
3074 while (it != mapBlockIndex.end()) {
3075 if (it->second->IsValid(BLOCK_VALID_TRANSACTIONS) && it->second->nChainTx && !setBlockIndexCandidates.value_comp()(it->second, chainActive.Tip())) {
3076 setBlockIndexCandidates.insert(it->second);
3077 }
3078 it++;
3079 }
3080
3081 InvalidChainFound(pindex);
3082 mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
3083 return true;
3084}
3085
3086bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) {
3087 AssertLockHeld(cs_main);

Callers 1

invalidateblockFunction · 0.85

Calls 12

DisconnectTipFunction · 0.85
GetArgFunction · 0.85
InvalidChainFoundFunction · 0.85
removeForReorgMethod · 0.80
TrimToSizeMethod · 0.80
insertMethod · 0.45
eraseMethod · 0.45
ContainsMethod · 0.45
TipMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected