| 1442 | } |
| 1443 | |
| 1444 | UniValue invalidateblock(const UniValue& params, bool fHelp) |
| 1445 | { |
| 1446 | if (fHelp || params.size() != 1) |
| 1447 | throw runtime_error( |
| 1448 | "invalidateblock \"hash\"\n" |
| 1449 | "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n" |
| 1450 | "\nArguments:\n" |
| 1451 | "1. hash (string, required) the hash of the block to mark as invalid\n" |
| 1452 | "\nResult:\n" |
| 1453 | "\nExamples:\n" + |
| 1454 | HelpExampleCli("invalidateblock", "\"blockhash\"") + HelpExampleRpc("invalidateblock", "\"blockhash\"")); |
| 1455 | |
| 1456 | std::string strHash = params[0].get_str(); |
| 1457 | uint256 hash(strHash); |
| 1458 | CValidationState state; |
| 1459 | |
| 1460 | { |
| 1461 | LOCK(cs_main); |
| 1462 | if (mapBlockIndex.count(hash) == 0) |
| 1463 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); |
| 1464 | |
| 1465 | CBlockIndex* pblockindex = mapBlockIndex[hash]; |
| 1466 | InvalidateBlock(state, Params(), pblockindex); |
| 1467 | } |
| 1468 | |
| 1469 | if (state.IsValid()) { |
| 1470 | ActivateBestChain(state, Params(), nullptr); |
| 1471 | } |
| 1472 | |
| 1473 | if (!state.IsValid()) { |
| 1474 | throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); |
| 1475 | } |
| 1476 | |
| 1477 | return NullUniValue; |
| 1478 | } |
| 1479 | |
| 1480 | UniValue reconsiderblock(const UniValue& params, bool fHelp) |
| 1481 | { |
nothing calls this directly
no test coverage detected