Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 1,500 Lines • ▼ Show 20 Lines | UniValue preciousblock(const Config &config, const JSONRPCRequest &request) { | ||||
if (!state.IsValid()) { | if (!state.IsValid()) { | ||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); | throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); | ||||
} | } | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
UniValue finalizeblock(const Config &config, const JSONRPCRequest &request) { | |||||
if (request.fHelp || request.params.size() != 1) { | |||||
throw std::runtime_error( | |||||
"finalizeblock \"blockhash\"\n" | |||||
"\nTreats a block as final. It cannot be reorged. Any chain \n " | |||||
"that does not contain block is invalid. Used on a less work \n" | |||||
jasonbcox: `block` -> `this block` otherwise it sounds ambiguous | |||||
" chain, it effectively PUTS YOU OUT OF CONSENSUS.\n" | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsAdd to the end: USE WITH CAUTION! jasonbcox: Add to the end: ` USE WITH CAUTION!` | |||||
"\nResult:\n" | |||||
"\nExamples:\n" + | |||||
HelpExampleCli("mostpreciousblock", "\"blockhash\"") + | |||||
HelpExampleRpc("mostpreciousblock", "\"blockhash\"")); | |||||
jasonbcoxUnsubmitted Not Done Inline Actionsmostpreciousblock -> finalizeblock jasonbcox: mostpreciousblock -> finalizeblock | |||||
} | |||||
std::string strHash = request.params[0].get_str(); | |||||
uint256 hash(uint256S(strHash)); | |||||
CValidationState state; | |||||
{ | |||||
LOCK(cs_main); | |||||
if (mapBlockIndex.count(hash) == 0) { | |||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); | |||||
} | |||||
CBlockIndex *pblockindex = mapBlockIndex[hash]; | |||||
FinalizeBlock(config, state, pblockindex); | |||||
} | |||||
if (state.IsValid()) { | |||||
ActivateBestChain(config, state); | |||||
} | |||||
if (!state.IsValid()) { | |||||
throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); | |||||
} | |||||
return NullUniValue; | |||||
} | |||||
UniValue invalidateblock(const Config &config, const JSONRPCRequest &request) { | UniValue invalidateblock(const Config &config, const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"invalidateblock \"blockhash\"\n" | "invalidateblock \"blockhash\"\n" | ||||
"\nPermanently marks a block as invalid, as if it " | "\nPermanently marks a block as invalid, as if it " | ||||
"violated a consensus rule.\n" | "violated a consensus rule.\n" | ||||
"\nArguments:\n" | "\nArguments:\n" | ||||
"1. \"blockhash\" (string, required) the hash of " | "1. \"blockhash\" (string, required) the hash of " | ||||
▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | static const ContextFreeRPCCommand commands[] = { | ||||
{ "blockchain", "getrawmempool", getrawmempool, {"verbose"} }, | { "blockchain", "getrawmempool", getrawmempool, {"verbose"} }, | ||||
{ "blockchain", "gettxout", gettxout, {"txid","n","include_mempool"} }, | { "blockchain", "gettxout", gettxout, {"txid","n","include_mempool"} }, | ||||
{ "blockchain", "gettxoutsetinfo", gettxoutsetinfo, {} }, | { "blockchain", "gettxoutsetinfo", gettxoutsetinfo, {} }, | ||||
{ "blockchain", "pruneblockchain", pruneblockchain, {"height"} }, | { "blockchain", "pruneblockchain", pruneblockchain, {"height"} }, | ||||
{ "blockchain", "verifychain", verifychain, {"checklevel","nblocks"} }, | { "blockchain", "verifychain", verifychain, {"checklevel","nblocks"} }, | ||||
{ "blockchain", "preciousblock", preciousblock, {"blockhash"} }, | { "blockchain", "preciousblock", preciousblock, {"blockhash"} }, | ||||
/* Not shown in help */ | /* Not shown in help */ | ||||
{ "hidden", "finalizeblock", finalizeblock, {"blockhash"} }, | |||||
{ "hidden", "invalidateblock", invalidateblock, {"blockhash"} }, | { "hidden", "invalidateblock", invalidateblock, {"blockhash"} }, | ||||
{ "hidden", "parkblock", parkblock, {"blockhash"} }, | { "hidden", "parkblock", parkblock, {"blockhash"} }, | ||||
{ "hidden", "reconsiderblock", reconsiderblock, {"blockhash"} }, | { "hidden", "reconsiderblock", reconsiderblock, {"blockhash"} }, | ||||
{ "hidden", "unparkblock", unparkblock, {"blockhash"} }, | { "hidden", "unparkblock", unparkblock, {"blockhash"} }, | ||||
{ "hidden", "waitfornewblock", waitfornewblock, {"timeout"} }, | { "hidden", "waitfornewblock", waitfornewblock, {"timeout"} }, | ||||
{ "hidden", "waitforblock", waitforblock, {"blockhash","timeout"} }, | { "hidden", "waitforblock", waitforblock, {"blockhash","timeout"} }, | ||||
{ "hidden", "waitforblockheight", waitforblockheight, {"height","timeout"} }, | { "hidden", "waitforblockheight", waitforblockheight, {"height","timeout"} }, | ||||
}; | }; | ||||
// clang-format on | // clang-format on | ||||
void RegisterBlockchainRPCCommands(CRPCTable &t) { | void RegisterBlockchainRPCCommands(CRPCTable &t) { | ||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | ||||
t.appendCommand(commands[vcidx].name, &commands[vcidx]); | t.appendCommand(commands[vcidx].name, &commands[vcidx]); | ||||
} | } | ||||
} | } |
block -> this block otherwise it sounds ambiguous