mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Merge #19405: rpc, cli: add network in/out connections to getnetworkinfo and -getinfo
581b343d5bAdd in/out connections to cli -getinfo (Jon Atack)d9cc13e88dUNIX_EPOCH_TIME fixup in rpc getnettotals (Jon Atack)1ab49b81cfAdd in/out connections to rpc getnetworkinfo (Jon Atack) Pull request description: This is basic info that is present in the GUI that I've been wishing to have exposed via the RPC and CLI without needing a bash workaround or script. For human users it would also be useful to have it in `-getinfo`. `bitcoin-cli getnetworkinfo` ``` "connections": 15, "connections_in": 6, "connections_out": 9, ``` `bitcoin-cli -getinfo` ``` "connections": { "in": 6, "out": 9, "total": 15 }, ``` Update the tests, RPC help, and release notes for the changes. Also fixup the `getnettotals` timemillis help while touching `rpc/net.cpp`. ----- Reviewers can manually test this PR by [building from source](https://jonatack.github.io/articles/how-to-compile-bitcoin-core-and-run-the-tests), launching bitcoind, and then running `bitcoin-cli -getinfo`, `bitcoin-cli getnetworkinfo`, `bitcoin-cli help getnetworkinfo`, and `bitcoin-cli help getnettotals` (for the UNIX epoch time change). ACKs for top commit: eriknylund: > tACK [581b343](581b343d5b) on master at [a0a422c](a0a422c34c), ran unit & functional tests and and confirmed changes on an existing datadir ✌️ benthecarman: tACK `581b343` willcl-ark: tACK for581b343d5b, this time rebased onto master at862fde88be. shesek: tACK `581b343`. This provides what I needed, thanks! n-thumann: tACK581b343on master ata0a422c, ran unit & functional tests and and confirmed changes on an existing datadir ✌️ Tree-SHA512: 08dd3ac8fefae401bd8253ff3ac027603c528eeccba53cedcb127771316173a7052fce44af8fa33ac98ebc4cf2a2b11cdefd949995d55e9b9a5942b876d00dc5
This commit is contained in:
@@ -414,7 +414,7 @@ static UniValue getnettotals(const JSONRPCRequest& request)
|
||||
{
|
||||
{RPCResult::Type::NUM, "totalbytesrecv", "Total bytes received"},
|
||||
{RPCResult::Type::NUM, "totalbytessent", "Total bytes sent"},
|
||||
{RPCResult::Type::NUM_TIME, "timemillis", "Current UNIX time in milliseconds"},
|
||||
{RPCResult::Type::NUM_TIME, "timemillis", "Current " + UNIX_EPOCH_TIME + " in milliseconds"},
|
||||
{RPCResult::Type::OBJ, "uploadtarget", "",
|
||||
{
|
||||
{RPCResult::Type::NUM, "timeframe", "Length of the measuring timeframe in seconds"},
|
||||
@@ -490,7 +490,9 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
|
||||
}},
|
||||
{RPCResult::Type::BOOL, "localrelay", "true if transaction relay is requested from peers"},
|
||||
{RPCResult::Type::NUM, "timeoffset", "the time offset"},
|
||||
{RPCResult::Type::NUM, "connections", "the number of connections"},
|
||||
{RPCResult::Type::NUM, "connections", "the total number of connections"},
|
||||
{RPCResult::Type::NUM, "connections_in", "the number of inbound connections"},
|
||||
{RPCResult::Type::NUM, "connections_out", "the number of outbound connections"},
|
||||
{RPCResult::Type::BOOL, "networkactive", "whether p2p networking is enabled"},
|
||||
{RPCResult::Type::ARR, "networks", "information per network",
|
||||
{
|
||||
@@ -538,7 +540,9 @@ static UniValue getnetworkinfo(const JSONRPCRequest& request)
|
||||
obj.pushKV("timeoffset", GetTimeOffset());
|
||||
if (node.connman) {
|
||||
obj.pushKV("networkactive", node.connman->GetNetworkActive());
|
||||
obj.pushKV("connections", (int)node.connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
|
||||
obj.pushKV("connections", (int)node.connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
|
||||
obj.pushKV("connections_in", (int)node.connman->GetNodeCount(CConnman::CONNECTIONS_IN));
|
||||
obj.pushKV("connections_out", (int)node.connman->GetNodeCount(CConnman::CONNECTIONS_OUT));
|
||||
}
|
||||
obj.pushKV("networks", GetNetworksInfo());
|
||||
obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()));
|
||||
|
||||
Reference in New Issue
Block a user