mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
Add in/out connections to cli -getinfo
This commit is contained in:
parent
d9cc13e88d
commit
581b343d5b
3 changed files with 21 additions and 2 deletions
|
@ -4,3 +4,9 @@
|
||||||
`connections_out`, that provide the number of inbound and outbound peer
|
`connections_out`, that provide the number of inbound and outbound peer
|
||||||
connections. These new fields are in addition to the existing `connections`
|
connections. These new fields are in addition to the existing `connections`
|
||||||
field, which returns the total number of peer connections. (#19405)
|
field, which returns the total number of peer connections. (#19405)
|
||||||
|
|
||||||
|
## CLI
|
||||||
|
|
||||||
|
- The `connections` field of `bitcoin-cli -getinfo` is expanded to return a JSON
|
||||||
|
object with `in`, `out` and `total` numbers of peer connections. It previously
|
||||||
|
returned a single integer value for the total number of peer connections. (#19405)
|
||||||
|
|
|
@ -271,7 +271,13 @@ public:
|
||||||
result.pushKV("headers", batch[ID_BLOCKCHAININFO]["result"]["headers"]);
|
result.pushKV("headers", batch[ID_BLOCKCHAININFO]["result"]["headers"]);
|
||||||
result.pushKV("verificationprogress", batch[ID_BLOCKCHAININFO]["result"]["verificationprogress"]);
|
result.pushKV("verificationprogress", batch[ID_BLOCKCHAININFO]["result"]["verificationprogress"]);
|
||||||
result.pushKV("timeoffset", batch[ID_NETWORKINFO]["result"]["timeoffset"]);
|
result.pushKV("timeoffset", batch[ID_NETWORKINFO]["result"]["timeoffset"]);
|
||||||
result.pushKV("connections", batch[ID_NETWORKINFO]["result"]["connections"]);
|
|
||||||
|
UniValue connections(UniValue::VOBJ);
|
||||||
|
connections.pushKV("in", batch[ID_NETWORKINFO]["result"]["connections_in"]);
|
||||||
|
connections.pushKV("out", batch[ID_NETWORKINFO]["result"]["connections_out"]);
|
||||||
|
connections.pushKV("total", batch[ID_NETWORKINFO]["result"]["connections"]);
|
||||||
|
result.pushKV("connections", connections);
|
||||||
|
|
||||||
result.pushKV("proxy", batch[ID_NETWORKINFO]["result"]["networks"][0]["proxy"]);
|
result.pushKV("proxy", batch[ID_NETWORKINFO]["result"]["networks"][0]["proxy"]);
|
||||||
result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]);
|
result.pushKV("difficulty", batch[ID_BLOCKCHAININFO]["result"]["difficulty"]);
|
||||||
result.pushKV("chain", UniValue(batch[ID_BLOCKCHAININFO]["result"]["chain"]));
|
result.pushKV("chain", UniValue(batch[ID_BLOCKCHAININFO]["result"]["chain"]));
|
||||||
|
|
|
@ -71,7 +71,14 @@ class TestBitcoinCli(BitcoinTestFramework):
|
||||||
assert_equal(cli_get_info['blocks'], blockchain_info['blocks'])
|
assert_equal(cli_get_info['blocks'], blockchain_info['blocks'])
|
||||||
assert_equal(cli_get_info['headers'], blockchain_info['headers'])
|
assert_equal(cli_get_info['headers'], blockchain_info['headers'])
|
||||||
assert_equal(cli_get_info['timeoffset'], network_info['timeoffset'])
|
assert_equal(cli_get_info['timeoffset'], network_info['timeoffset'])
|
||||||
assert_equal(cli_get_info['connections'], network_info['connections'])
|
assert_equal(
|
||||||
|
cli_get_info['connections'],
|
||||||
|
{
|
||||||
|
'in': network_info['connections_in'],
|
||||||
|
'out': network_info['connections_out'],
|
||||||
|
'total': network_info['connections']
|
||||||
|
}
|
||||||
|
)
|
||||||
assert_equal(cli_get_info['proxy'], network_info['networks'][0]['proxy'])
|
assert_equal(cli_get_info['proxy'], network_info['networks'][0]['proxy'])
|
||||||
assert_equal(cli_get_info['difficulty'], blockchain_info['difficulty'])
|
assert_equal(cli_get_info['difficulty'], blockchain_info['difficulty'])
|
||||||
assert_equal(cli_get_info['chain'], blockchain_info['chain'])
|
assert_equal(cli_get_info['chain'], blockchain_info['chain'])
|
||||||
|
|
Loading…
Add table
Reference in a new issue