Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,651 Lines • ▼ Show 20 Lines | static UniValue preciousblock(const Config &config, | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
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"); | ||||
} | } | ||||
} | } | ||||
CValidationState state; | BlockValidationState state; | ||||
PreciousBlock(config, state, pblockindex); | PreciousBlock(config, state, pblockindex); | ||||
if (!state.IsValid()) { | if (!state.IsValid()) { | ||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); | throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
Show All 12 Lines | RPCHelpMan{ | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("invalidateblock", "\"blockhash\"") + | RPCExamples{HelpExampleCli("invalidateblock", "\"blockhash\"") + | ||||
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)); | ||||
CValidationState state; | BlockValidationState state; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CBlockIndex *pblockindex = LookupBlockIndex(hash); | CBlockIndex *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"); | ||||
} | } | ||||
Show All 23 Lines | RPCHelpMan{ | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("invalidateblock", "\"blockhash\"") + | RPCExamples{HelpExampleCli("invalidateblock", "\"blockhash\"") + | ||||
HelpExampleRpc("invalidateblock", "\"blockhash\"")}, | HelpExampleRpc("invalidateblock", "\"blockhash\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
const BlockHash hash(ParseHashV(request.params[0], "blockhash")); | const BlockHash hash(ParseHashV(request.params[0], "blockhash")); | ||||
CValidationState state; | BlockValidationState state; | ||||
CBlockIndex *pblockindex; | CBlockIndex *pblockindex; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
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"); | ||||
} | } | ||||
Show All 22 Lines | RPCHelpMan{ | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{HelpExampleCli("parkblock", "\"blockhash\"") + | RPCExamples{HelpExampleCli("parkblock", "\"blockhash\"") + | ||||
HelpExampleRpc("parkblock", "\"blockhash\"")}, | HelpExampleRpc("parkblock", "\"blockhash\"")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
const std::string strHash = request.params[0].get_str(); | const std::string strHash = request.params[0].get_str(); | ||||
const BlockHash hash(uint256S(strHash)); | const BlockHash hash(uint256S(strHash)); | ||||
CValidationState state; | |||||
CBlockIndex *pblockindex; | CBlockIndex *pblockindex; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
if (mapBlockIndex.count(hash) == 0) { | if (mapBlockIndex.count(hash) == 0) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
pblockindex = mapBlockIndex[hash]; | pblockindex = mapBlockIndex[hash]; | ||||
} | } | ||||
BlockValidationState state; | |||||
ParkBlock(config, state, pblockindex); | ParkBlock(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, state.GetRejectReason()); | throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); | ||||
Show All 26 Lines | const BlockHash hash(ParseHashV(request.params[0], "blockhash")); | ||||
CBlockIndex *pblockindex = LookupBlockIndex(hash); | CBlockIndex *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"); | ||||
} | } | ||||
ResetBlockFailureFlags(pblockindex); | ResetBlockFailureFlags(pblockindex); | ||||
} | } | ||||
CValidationState state; | BlockValidationState state; | ||||
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)); | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
Show All 22 Lines | const BlockHash hash(uint256S(strHash)); | ||||
if (mapBlockIndex.count(hash) == 0) { | if (mapBlockIndex.count(hash) == 0) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | ||||
} | } | ||||
CBlockIndex *pblockindex = mapBlockIndex[hash]; | CBlockIndex *pblockindex = mapBlockIndex[hash]; | ||||
UnparkBlockAndChildren(pblockindex); | UnparkBlockAndChildren(pblockindex); | ||||
} | } | ||||
CValidationState state; | BlockValidationState state; | ||||
ActivateBestChain(config, state); | ActivateBestChain(config, state); | ||||
if (!state.IsValid()) { | if (!state.IsValid()) { | ||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); | throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 802 Lines • Show Last 20 Lines |