Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
throw std::runtime_error(RPCHelpMan{ | throw std::runtime_error(RPCHelpMan{ | ||||
"getmininginfo", | "getmininginfo", | ||||
"\nReturns a json object containing mining-related " | "\nReturns a json object containing mining-related " | ||||
"information.", | "information.", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | "{\n" | ||||
" \"blocks\": nnn, (numeric) The current block\n" | " \"blocks\": nnn, (numeric) The current block\n" | ||||
" \"currentblocksize\": nnn, (numeric) The last block size\n" | " \"currentblocksize\": nnn, (numeric, optional) The block " | ||||
" \"currentblocktx\": nnn, (numeric) The last block " | "size of the last assembled block (only present if a block was " | ||||
"transaction\n" | "ever assembled)\n" | ||||
" \"currentblocktx\": nnn, (numeric, optional) The number " | |||||
"of block transactions of the last assembled block (only " | |||||
"present if a block was ever assembled)\n" | |||||
" \"difficulty\": xxx.xxxxx (numeric) The current " | " \"difficulty\": xxx.xxxxx (numeric) The current " | ||||
"difficulty\n" | "difficulty\n" | ||||
" \"networkhashps\": nnn, (numeric) The network hashes " | " \"networkhashps\": nnn, (numeric) The network hashes " | ||||
"per second\n" | "per second\n" | ||||
" \"pooledtx\": n (numeric) The size of the " | " \"pooledtx\": n (numeric) The size of the " | ||||
"mempool\n" | "mempool\n" | ||||
" \"chain\": \"xxxx\", (string) current network " | " \"chain\": \"xxxx\", (string) current network " | ||||
"name as defined in BIP70 (main, test, regtest)\n" | "name as defined in BIP70 (main, test, regtest)\n" | ||||
" \"warnings\": \"...\" (string) any network and " | " \"warnings\": \"...\" (string) any network and " | ||||
"blockchain warnings\n" | "blockchain warnings\n" | ||||
"}\n"}, | "}\n"}, | ||||
RPCExamples{HelpExampleCli("getmininginfo", "") + | RPCExamples{HelpExampleCli("getmininginfo", "") + | ||||
HelpExampleRpc("getmininginfo", "")}, | HelpExampleRpc("getmininginfo", "")}, | ||||
} | } | ||||
.ToStringWithResultsAndExamples()); | .ToStringWithResultsAndExamples()); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("blocks", int(::ChainActive().Height())); | obj.pushKV("blocks", int(::ChainActive().Height())); | ||||
obj.pushKV("currentblocksize", uint64_t(nLastBlockSize)); | if (BlockAssembler::m_last_block_size) { | ||||
obj.pushKV("currentblocktx", uint64_t(nLastBlockTx)); | obj.pushKV("currentblocksize", *BlockAssembler::m_last_block_size); | ||||
} | |||||
if (BlockAssembler::m_last_block_num_txs) { | |||||
obj.pushKV("currentblocktx", *BlockAssembler::m_last_block_num_txs); | |||||
} | |||||
obj.pushKV("difficulty", double(GetDifficulty(::ChainActive().Tip()))); | obj.pushKV("difficulty", double(GetDifficulty(::ChainActive().Tip()))); | ||||
obj.pushKV("networkhashps", getnetworkhashps(config, request)); | obj.pushKV("networkhashps", getnetworkhashps(config, request)); | ||||
obj.pushKV("pooledtx", uint64_t(g_mempool.size())); | obj.pushKV("pooledtx", uint64_t(g_mempool.size())); | ||||
obj.pushKV("chain", config.GetChainParams().NetworkIDString()); | obj.pushKV("chain", config.GetChainParams().NetworkIDString()); | ||||
obj.pushKV("warnings", GetWarnings("statusbar")); | obj.pushKV("warnings", GetWarnings("statusbar")); | ||||
return obj; | return obj; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 610 Lines • Show Last 20 Lines |