| 1726 | } |
| 1727 | |
| 1728 | void 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 | |
| 1749 | static RPCMethod invalidateblock() |
| 1750 | { |
no test coverage detected