Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,591 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 1) { | ||||
HelpExampleCli("finalizeblock", "\"blockhash\"") + | HelpExampleCli("finalizeblock", "\"blockhash\"") + | ||||
HelpExampleRpc("finalizeblock", "\"blockhash\"")); | HelpExampleRpc("finalizeblock", "\"blockhash\"")); | ||||
} | } | ||||
std::string strHash = request.params[0].get_str(); | std::string strHash = request.params[0].get_str(); | ||||
BlockHash hash(uint256S(strHash)); | BlockHash hash(uint256S(strHash)); | ||||
CValidationState state; | CValidationState state; | ||||
CBlockIndex *pblockindex; | |||||
{ | { | ||||
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"); | ||||
} | } | ||||
FinalizeBlockAndInvalidate(config, state, pblockindex); | |||||
} | } | ||||
FinalizeBlockAndInvalidate(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 918 Lines • Show Last 20 Lines |