MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / invalidateblock

Function invalidateblock

src/rpc/blockchain.cpp:1570–1607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1568}
1569
1570static 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
1609static UniValue reconsiderblock(const JSONRPCRequest& request)
1610{

Callers

nothing calls this directly

Calls 11

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
uint256SFunction · 0.85
LookupBlockIndexFunction · 0.85
JSONRPCErrorFunction · 0.85
InvalidateBlockFunction · 0.85
ActivateBestChainFunction · 0.85
FormatStateMessageFunction · 0.85
ParamsClass · 0.50
sizeMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected