Skip to content

Commit 174848f

Browse files
committed
rpc: Add connections_onion_only to getnetworkinfo output
1 parent 0ea8ba4 commit 174848f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/net.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2733,13 +2733,16 @@ ConnCounts CConnman::ConnectionCounts()
27332733
{
27342734
int num_in{0};
27352735
int num_out{0};
2736+
bool onion_only{false};
27362737
{
27372738
LOCK(cs_vNodes);
2739+
if (!vNodes.empty()) onion_only = true;
27382740
for (const auto& pnode : vNodes) {
27392741
pnode->IsInboundConn() ? ++num_in : ++num_out;
2742+
if (pnode->ConnectedThroughNetwork() != NET_ONION) onion_only = false;
27402743
}
27412744
}
2742-
return {num_in, num_out};
2745+
return {num_in, num_out, onion_only};
27432746
}
27442747

27452748
void CConnman::GetNodeStats(std::vector<CNodeStats>& vstats)

src/net.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,14 @@ struct ConnCounts
188188
const int all{0};
189189
const int in{0};
190190
const int out{0};
191+
const bool onion_only{false};
191192

192193
ConnCounts()
193194
{
194195
}
195196

196-
ConnCounts(int num_in, int num_out)
197-
: all(num_in + num_out), in(num_in), out(num_out)
197+
ConnCounts(int num_in, int num_out, bool is_onion_only)
198+
: all(num_in + num_out), in(num_in), out(num_out), onion_only(is_onion_only)
198199
{
199200
}
200201
};

src/rpc/net.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,11 @@ static RPCHelpMan getnetworkinfo()
533533
}},
534534
{RPCResult::Type::BOOL, "localrelay", "true if transaction relay is requested from peers"},
535535
{RPCResult::Type::NUM, "timeoffset", "the time offset"},
536+
{RPCResult::Type::BOOL, "networkactive", "whether p2p networking is enabled"},
536537
{RPCResult::Type::NUM, "connections", "the total number of connections"},
537538
{RPCResult::Type::NUM, "connections_in", "the number of inbound connections"},
538539
{RPCResult::Type::NUM, "connections_out", "the number of outbound connections"},
539-
{RPCResult::Type::BOOL, "networkactive", "whether p2p networking is enabled"},
540+
{RPCResult::Type::BOOL, "connections_onion_only", "whether all connection are through the onion network"},
540541
{RPCResult::Type::ARR, "networks", "information per network",
541542
{
542543
{RPCResult::Type::OBJ, "", "",
@@ -587,6 +588,7 @@ static RPCHelpMan getnetworkinfo()
587588
obj.pushKV("connections", conn_counts.all);
588589
obj.pushKV("connections_in", conn_counts.in);
589590
obj.pushKV("connections_out", conn_counts.out);
591+
obj.pushKV("connections_onion_only", conn_counts.onion_only);
590592
}
591593
obj.pushKV("networks", GetNetworksInfo());
592594
obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()));

0 commit comments

Comments
 (0)