mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
rpc: add target to getmininginfo result
This commit is contained in:
parent
2a7bfebd5e
commit
baa504fdfa
2 changed files with 5 additions and 0 deletions
|
@ -423,6 +423,7 @@ static RPCHelpMan getmininginfo()
|
||||||
{RPCResult::Type::NUM, "currentblocktx", /*optional=*/true, "The number of block transactions of the last assembled block (only present if a block was ever assembled)"},
|
{RPCResult::Type::NUM, "currentblocktx", /*optional=*/true, "The number of block transactions of the last assembled block (only present if a block was ever assembled)"},
|
||||||
{RPCResult::Type::STR_HEX, "bits", "The current nBits, compact representation of the block difficulty target"},
|
{RPCResult::Type::STR_HEX, "bits", "The current nBits, compact representation of the block difficulty target"},
|
||||||
{RPCResult::Type::NUM, "difficulty", "The current difficulty"},
|
{RPCResult::Type::NUM, "difficulty", "The current difficulty"},
|
||||||
|
{RPCResult::Type::STR_HEX, "target", "The current target"},
|
||||||
{RPCResult::Type::NUM, "networkhashps", "The network hashes per second"},
|
{RPCResult::Type::NUM, "networkhashps", "The network hashes per second"},
|
||||||
{RPCResult::Type::NUM, "pooledtx", "The size of the mempool"},
|
{RPCResult::Type::NUM, "pooledtx", "The size of the mempool"},
|
||||||
{RPCResult::Type::STR, "chain", "current network name (" LIST_CHAIN_NAMES ")"},
|
{RPCResult::Type::STR, "chain", "current network name (" LIST_CHAIN_NAMES ")"},
|
||||||
|
@ -455,6 +456,7 @@ static RPCHelpMan getmininginfo()
|
||||||
if (BlockAssembler::m_last_block_num_txs) obj.pushKV("currentblocktx", *BlockAssembler::m_last_block_num_txs);
|
if (BlockAssembler::m_last_block_num_txs) obj.pushKV("currentblocktx", *BlockAssembler::m_last_block_num_txs);
|
||||||
obj.pushKV("bits", strprintf("%08x", tip.nBits));
|
obj.pushKV("bits", strprintf("%08x", tip.nBits));
|
||||||
obj.pushKV("difficulty", GetDifficulty(tip));
|
obj.pushKV("difficulty", GetDifficulty(tip));
|
||||||
|
obj.pushKV("target", GetTarget(tip, chainman.GetConsensus().powLimit).GetHex());
|
||||||
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
|
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
|
||||||
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
obj.pushKV("pooledtx", (uint64_t)mempool.size());
|
||||||
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
|
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
|
||||||
|
|
|
@ -17,7 +17,9 @@ from test_framework.blocktools import (
|
||||||
NORMAL_GBT_REQUEST_PARAMS,
|
NORMAL_GBT_REQUEST_PARAMS,
|
||||||
TIME_GENESIS_BLOCK,
|
TIME_GENESIS_BLOCK,
|
||||||
REGTEST_N_BITS,
|
REGTEST_N_BITS,
|
||||||
|
REGTEST_TARGET,
|
||||||
nbits_str,
|
nbits_str,
|
||||||
|
target_str,
|
||||||
)
|
)
|
||||||
from test_framework.messages import (
|
from test_framework.messages import (
|
||||||
BLOCK_HEADER_SIZE,
|
BLOCK_HEADER_SIZE,
|
||||||
|
@ -209,6 +211,7 @@ class MiningTest(BitcoinTestFramework):
|
||||||
assert 'currentblocktx' not in mining_info
|
assert 'currentblocktx' not in mining_info
|
||||||
assert 'currentblockweight' not in mining_info
|
assert 'currentblockweight' not in mining_info
|
||||||
assert_equal(mining_info['bits'], nbits_str(REGTEST_N_BITS))
|
assert_equal(mining_info['bits'], nbits_str(REGTEST_N_BITS))
|
||||||
|
assert_equal(mining_info['target'], target_str(REGTEST_TARGET))
|
||||||
assert_equal(mining_info['difficulty'], Decimal('4.656542373906925E-10'))
|
assert_equal(mining_info['difficulty'], Decimal('4.656542373906925E-10'))
|
||||||
assert_equal(mining_info['networkhashps'], Decimal('0.003333333333333334'))
|
assert_equal(mining_info['networkhashps'], Decimal('0.003333333333333334'))
|
||||||
assert_equal(mining_info['pooledtx'], 0)
|
assert_equal(mining_info['pooledtx'], 0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue