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

Function invalidateblock

src/rpc/rpcblockchain.cpp:338–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338Value invalidateblock(const Array& params, bool fHelp) {
339 if (fHelp || params.size() != 1) {
340 throw runtime_error(
341 "invalidateblock \"hash\"\n"
342 "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n"
343 "\nArguments:\n"
344 "1. \"hash\" (string, required) the hash of the block to mark as invalid\n"
345 "\nResult:\n"
346 "\nExamples:\n"
347 + HelpExampleRpc("invalidateblock", "\"hash\""));
348 }
349
350 std::string strHash = params[0].get_str();
351 uint256 hash(uint256S(strHash));
352 CValidationState state;
353
354 {
355 LOCK(cs_main);
356 if (mapBlockIndex.count(hash) == 0)
357 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
358
359 CBlockIndex* pBlockIndex = mapBlockIndex[hash];
360 InvalidateBlock(state, pBlockIndex);
361 }
362
363 if (state.IsValid()) {
364 ActivateBestChain(state);
365 }
366
367 if (!state.IsValid()) {
368 throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
369 }
370
371 Object obj;
372 obj.push_back(Pair("msg", "success"));
373 return obj;
374}
375
376Value reconsiderblock(const Array& params, bool fHelp) {
377 if (fHelp || params.size() < 1 || params.size() > 2) {

Callers

nothing calls this directly

Calls 11

HelpExampleRpcFunction · 0.85
uint256SFunction · 0.85
JSONRPCErrorFunction · 0.85
InvalidateBlockFunction · 0.85
ActivateBestChainFunction · 0.85
PairClass · 0.85
GetRejectReasonMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45
countMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected