MCPcopy Create free account
hub / github.com/LUX-Core/lux / invalidateblock

Function invalidateblock

src/rpcblockchain.cpp:1444–1478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1442}
1443
1444UniValue 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
1480UniValue reconsiderblock(const UniValue& params, bool fHelp)
1481{

Callers

nothing calls this directly

Calls 11

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
InvalidateBlockFunction · 0.85
ActivateBestChainFunction · 0.85
get_strMethod · 0.80
GetRejectReasonMethod · 0.80
ParamsClass · 0.70
sizeMethod · 0.45
countMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected