Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,682 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
HelpExampleRpc("invalidateblock", "\"blockhash\"")}, | HelpExampleRpc("invalidateblock", "\"blockhash\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
std::string strHash = request.params[0].get_str(); | std::string strHash = request.params[0].get_str(); | ||||
BlockHash hash(uint256S(strHash)); | BlockHash hash(uint256S(strHash)); | ||||
BlockValidationState state; | BlockValidationState state; | ||||
CBlockIndex *pblockindex{nullptr}; | |||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CBlockIndex *pblockindex = LookupBlockIndex(hash); | pblockindex = LookupBlockIndex(hash); | ||||
if (!pblockindex) { | if (!pblockindex) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
} // end of locked cs_main scope | |||||
::ChainstateActive().FinalizeBlock(config, state, pblockindex); | ::ChainstateActive().FinalizeBlock(config, state, pblockindex); | ||||
} | |||||
if (state.IsValid()) { | if (state.IsValid()) { | ||||
ActivateBestChain(config, state); | ActivateBestChain(config, state); | ||||
} | } | ||||
if (!state.IsValid()) { | if (!state.IsValid()) { | ||||
throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state)); | throw JSONRPCError(RPC_DATABASE_ERROR, FormatStateMessage(state)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 963 Lines • Show Last 20 Lines |