MCPcopy Create free account
hub / github.com/ElementsProject/elements / reconsiderblock

Function reconsiderblock

src/rpc/blockchain.cpp:2132–2170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2130}
2131
2132static RPCHelpMan reconsiderblock()
2133{
2134 return RPCHelpMan{"reconsiderblock",
2135 "\nRemoves invalidity status of a block, its ancestors and its descendants, reconsider them for activation.\n"
2136 "This can be used to undo the effects of invalidateblock.\n",
2137 {
2138 {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "the hash of the block to reconsider"},
2139 },
2140 RPCResult{RPCResult::Type::NONE, "", ""},
2141 RPCExamples{
2142 HelpExampleCli("reconsiderblock", "\"blockhash\"")
2143 + HelpExampleRpc("reconsiderblock", "\"blockhash\"")
2144 },
2145 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
2146{
2147 ChainstateManager& chainman = EnsureAnyChainman(request.context);
2148 uint256 hash(ParseHashV(request.params[0], "blockhash"));
2149
2150 {
2151 LOCK(cs_main);
2152 CBlockIndex* pblockindex = chainman.m_blockman.LookupBlockIndex(hash);
2153 if (!pblockindex) {
2154 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
2155 }
2156
2157 chainman.ActiveChainstate().ResetBlockFailureFlags(pblockindex);
2158 }
2159
2160 BlockValidationState state;
2161 chainman.ActiveChainstate().ActivateBestChain(state);
2162
2163 if (!state.IsValid()) {
2164 throw JSONRPCError(RPC_DATABASE_ERROR, state.ToString());
2165 }
2166
2167 return NullUniValue;
2168},
2169 };
2170}
2171
2172static RPCHelpMan getchaintxstats()
2173{

Callers

nothing calls this directly

Calls 9

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
ParseHashVFunction · 0.85
JSONRPCErrorFunction · 0.85
LookupBlockIndexMethod · 0.80
ActivateBestChainMethod · 0.80
IsValidMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected