MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / disconnectblock

Function disconnectblock

src/rpc/rpctx.cpp:704–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702}
703
704Value disconnectblock(const Array& params, bool fHelp) {
705 if (fHelp || params.size() != 1) {
706 throw runtime_error("disconnectblock \"numbers\"\n"
707 "\ndisconnect block\n"
708 "\nArguments:\n"
709 "1. \"number \" (numeric, required) the number of block(s) to be disconnected\n"
710 "\nResult:\n"
711 "\"disconnect result\" (bool) \n"
712 "\nExamples:\n"
713 + HelpExampleCli("disconnectblock", "\"1\"")
714 + "\nAs json rpc call\n"
715 + HelpExampleRpc("disconnectblock", "\"1\""));
716 }
717 int32_t number = params[0].get_int();
718
719
720 if (number >= chainActive.Height())
721 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid number");
722
723 if (number > 0) {
724 CValidationState state;
725 do {
726 CBlockIndex * pTipIndex = chainActive.Tip();
727 if (!DisconnectTip(state))
728 throw JSONRPCError(RPC_MISC_ERROR, "DisconnectTip err");
729
730 chainMostWork.SetTip(pTipIndex->pprev);
731 if (!EraseBlockIndexFromSet(pTipIndex))
732 throw JSONRPCError(RPC_MISC_ERROR, "EraseBlockIndexFromSet err");
733
734 if (!pCdMan->pBlockIndexDb->EraseBlockIndex(pTipIndex->GetBlockHash()))
735 throw JSONRPCError(RPC_MISC_ERROR, "EraseBlockIndex err");
736
737 mapBlockIndex.erase(pTipIndex->GetBlockHash());
738 } while (--number);
739 }
740
741 Object obj;
742 obj.push_back(
743 Pair("tip", strprintf("hash:%s hight:%s", chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height())));
744
745 return obj;
746}
747
748Value listcontracts(const Array& params, bool fHelp) {
749 if (fHelp || params.size() != 1) {

Callers

nothing calls this directly

Calls 15

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
JSONRPCErrorFunction · 0.85
DisconnectTipFunction · 0.85
EraseBlockIndexFromSetFunction · 0.85
PairClass · 0.85
get_intMethod · 0.80
HeightMethod · 0.80
TipMethod · 0.80
SetTipMethod · 0.80
EraseBlockIndexMethod · 0.80
push_backMethod · 0.80

Tested by

no test coverage detected