| 1568 | } |
| 1569 | |
| 1570 | static UniValue invalidateblock(const JSONRPCRequest& request) |
| 1571 | { |
| 1572 | if (request.fHelp || request.params.size() != 1) |
| 1573 | throw std::runtime_error( |
| 1574 | "invalidateblock \"blockhash\"\n" |
| 1575 | "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n" |
| 1576 | "\nArguments:\n" |
| 1577 | "1. \"blockhash\" (string, required) the hash of the block to mark as invalid\n" |
| 1578 | "\nResult:\n" |
| 1579 | "\nExamples:\n" |
| 1580 | + HelpExampleCli("invalidateblock", "\"blockhash\"") |
| 1581 | + HelpExampleRpc("invalidateblock", "\"blockhash\"") |
| 1582 | ); |
| 1583 | |
| 1584 | std::string strHash = request.params[0].get_str(); |
| 1585 | uint256 hash(uint256S(strHash)); |
| 1586 | CValidationState state; |
| 1587 | |
| 1588 | { |
| 1589 | LOCK(cs_main); |
| 1590 | CBlockIndex* pblockindex = LookupBlockIndex(hash); |
| 1591 | if (!pblockindex) { |
| 1592 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); |
| 1593 | } |
| 1594 | |
| 1595 | InvalidateBlock(state, Params(), pblockindex); |
| 1596 | } |
| 1597 | |
| 1598 | if (state.IsValid()) { |
| 1599 | ActivateBestChain(state, Params()); |
| 1600 | } |
| 1601 | |
| 1602 | if (!state.IsValid()) { |
| 1603 | throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state)); |
| 1604 | } |
| 1605 | |
| 1606 | return NullUniValue; |
| 1607 | } |
| 1608 | |
| 1609 | static UniValue reconsiderblock(const JSONRPCRequest& request) |
| 1610 | { |
nothing calls this directly
no test coverage detected