mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
[rpc] mining: Omit uninitialized currentblockweight, currentblocktx
This commit is contained in:
@@ -187,36 +187,36 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
|
||||
|
||||
static UniValue getmininginfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
if (request.fHelp || request.params.size() != 0) {
|
||||
throw std::runtime_error(
|
||||
RPCHelpMan{"getmininginfo",
|
||||
"\nReturns a json object containing mining-related information.",
|
||||
{},
|
||||
RPCResult{
|
||||
"{\n"
|
||||
" \"blocks\": nnn, (numeric) The current block\n"
|
||||
" \"currentblockweight\": nnn, (numeric) The last block weight\n"
|
||||
" \"currentblocktx\": nnn, (numeric) The last block transaction\n"
|
||||
" \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n"
|
||||
" \"networkhashps\": nnn, (numeric) The network hashes per second\n"
|
||||
" \"pooledtx\": n (numeric) The size of the mempool\n"
|
||||
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
|
||||
" \"warnings\": \"...\" (string) any network and blockchain warnings\n"
|
||||
"}\n"
|
||||
"{\n"
|
||||
" \"blocks\": nnn, (numeric) The current block\n"
|
||||
" \"currentblockweight\": nnn, (numeric, optional) The block weight of the last assembled block (only present if a block was 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\n"
|
||||
" \"networkhashps\": nnn, (numeric) The network hashes per second\n"
|
||||
" \"pooledtx\": n (numeric) The size of the mempool\n"
|
||||
" \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n"
|
||||
" \"warnings\": \"...\" (string) any network and blockchain warnings\n"
|
||||
"}\n"
|
||||
},
|
||||
RPCExamples{
|
||||
HelpExampleCli("getmininginfo", "")
|
||||
+ HelpExampleRpc("getmininginfo", "")
|
||||
},
|
||||
}.ToString());
|
||||
|
||||
}
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("blocks", (int)chainActive.Height());
|
||||
obj.pushKV("currentblockweight", (uint64_t)nLastBlockWeight);
|
||||
obj.pushKV("currentblocktx", (uint64_t)nLastBlockTx);
|
||||
if (BlockAssembler::m_last_block_weight) obj.pushKV("currentblockweight", *BlockAssembler::m_last_block_weight);
|
||||
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("networkhashps", getnetworkhashps(request));
|
||||
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
||||
|
||||
Reference in New Issue
Block a user