Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/blockchain.cpp
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"\"hex\" (string) the block hash hex encoded\n" | "\"hex\" (string) the block hash hex encoded\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getbestblockhash", "") + | HelpExampleCli("getbestblockhash", "") + | ||||
HelpExampleRpc("getbestblockhash", "")); | HelpExampleRpc("getbestblockhash", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
LogPrint(BCLog::RPC, "getbestblockhash called\n"); | |||||
return chainActive.Tip()->GetBlockHash().GetHex(); | return chainActive.Tip()->GetBlockHash().GetHex(); | ||||
} | } | ||||
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *pindex) { | void RPCNotifyBlockChange(bool ibd, const CBlockIndex *pindex) { | ||||
if (pindex) { | if (pindex) { | ||||
std::lock_guard<std::mutex> lock(cs_blockchange); | std::lock_guard<std::mutex> lock(cs_blockchange); | ||||
latestblock.hash = pindex->GetBlockHash(); | latestblock.hash = pindex->GetBlockHash(); | ||||
latestblock.height = pindex->nHeight; | latestblock.height = pindex->nHeight; | ||||
▲ Show 20 Lines • Show All 786 Lines • ▼ Show 20 Lines | if (chainHeight < config.GetChainParams().PruneAfterHeight()) { | ||||
throw JSONRPCError(RPC_MISC_ERROR, | throw JSONRPCError(RPC_MISC_ERROR, | ||||
"Blockchain is too short for pruning."); | "Blockchain is too short for pruning."); | ||||
} else if (height > chainHeight) { | } else if (height > chainHeight) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"Blockchain is shorter than the attempted prune height."); | "Blockchain is shorter than the attempted prune height."); | ||||
} else if (height > chainHeight - MIN_BLOCKS_TO_KEEP) { | } else if (height > chainHeight - MIN_BLOCKS_TO_KEEP) { | ||||
LogPrint(BCLog::RPC, "Attempt to prune blocks close to the tip. " | LogPrint(BCLog::RPC, "Attempt to prune blocks close to the tip. " | ||||
"Retaining the minimum number of blocks."); | "Retaining the minimum number of blocks.\n"); | ||||
height = chainHeight - MIN_BLOCKS_TO_KEEP; | height = chainHeight - MIN_BLOCKS_TO_KEEP; | ||||
} | } | ||||
PruneBlockFilesManual(height); | PruneBlockFilesManual(height); | ||||
return uint64_t(height); | return uint64_t(height); | ||||
} | } | ||||
UniValue gettxoutsetinfo(const Config &config, const JSONRPCRequest &request) { | UniValue gettxoutsetinfo(const Config &config, const JSONRPCRequest &request) { | ||||
▲ Show 20 Lines • Show All 572 Lines • ▼ Show 20 Lines | UniValue invalidateblock(const Config &config, const JSONRPCRequest &request) { | ||||
} | } | ||||
std::string strHash = request.params[0].get_str(); | std::string strHash = request.params[0].get_str(); | ||||
uint256 hash(uint256S(strHash)); | uint256 hash(uint256S(strHash)); | ||||
CValidationState state; | CValidationState state; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
LogPrint(BCLog::RPC, "invalidateblock called\n"); | |||||
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]; | ||||
InvalidateBlock(config, state, pblockindex); | InvalidateBlock(config, state, pblockindex); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |