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

Function InvalidateBlock

src/rpc/blockchain.cpp:1728–1747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1726}
1727
1728void InvalidateBlock(ChainstateManager& chainman, const uint256 block_hash) {
1729 BlockValidationState state;
1730 CBlockIndex* pblockindex;
1731 {
1732 LOCK(chainman.GetMutex());
1733 pblockindex = chainman.m_blockman.LookupBlockIndex(block_hash);
1734 if (!pblockindex) {
1735 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
1736 }
1737 }
1738 chainman.ActiveChainstate().InvalidateBlock(state, pblockindex);
1739
1740 if (state.IsValid()) {
1741 chainman.ActiveChainstate().ActivateBestChain(state);
1742 }
1743
1744 if (!state.IsValid()) {
1745 throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
1746 }
1747}
1748
1749static RPCMethod invalidateblock()
1750{

Callers 1

invalidateblockFunction · 0.85

Calls 6

JSONRPCErrorFunction · 0.85
LookupBlockIndexMethod · 0.80
InvalidateBlockMethod · 0.80
ActivateBestChainMethod · 0.80
IsValidMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected