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

Function reconsiderblock

src/rpc/rpcblockchain.cpp:376–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374}
375
376Value reconsiderblock(const Array& params, bool fHelp) {
377 if (fHelp || params.size() < 1 || params.size() > 2) {
378 throw runtime_error(
379 "reconsiderblock \"hash\" [children]\n"
380 "\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n"
381 "This can be used to undo the effects of invalidateblock.\n"
382 "\nArguments:\n"
383 "1. hash (string, required) the hash of the block to reconsider\n"
384 "2. children (bool, optional) reconsider all children of the block, default is false"
385 "\nResult:\n"
386 "\nExamples:\n"
387 + HelpExampleRpc("reconsiderblock", "\"hash\" false"));
388 }
389
390 std::string strHash = params[0].get_str();
391 bool children = params.size() > 1 ? params[1].get_bool() : false;
392 uint256 hash(uint256S(strHash));
393 CValidationState state;
394
395 {
396 LOCK(cs_main);
397 if (mapBlockIndex.count(hash) == 0)
398 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
399
400 CBlockIndex* pBlockIndex = mapBlockIndex[hash];
401 ReconsiderBlock(state, pBlockIndex, children);
402 }
403
404 if (state.IsValid()) {
405 ActivateBestChain(state);
406 }
407
408 if (!state.IsValid()) {
409 throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason());
410 }
411
412 Object obj;
413 obj.push_back(Pair("msg", "success"));
414 return obj;
415}
416
417
418class TpsTester {

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected