Skip to content

Commit cb9764b

Browse files
committed
Merge bitcoin/bitcoin#26109: rpc, doc: getpeerinfo updates
a3789c7 Improve getpeerinfo pingtime, minping, and pingwait help docs (Jon Atack) df660dd Update getpeerinfo/-netinfo/TxRelay#m_relay_txs relaytxes docs (for v24 backport) (Jon Atack) 1f44854 Always return getpeerinfo "minfeefilter" field (for v24 backport) (Jon Atack) 9cd6682 Make getpeerinfo field order consistent with its help (for v24 backport) (Jon Atack) Pull request description: Various updates and fixups, mostly targeting v24. Please refer to the commit messages for details. ACKs for top commit: achow101: ACK a3789c7 brunoerg: ACK a3789c7 vasild: ACK a3789c7 Tree-SHA512: b8586a9b83c1b18786b5ac1fc1dba91573c13225fc2cfc8d078f4220967c95056354f6be13327f33b4fcf3e9d5310fa4e1bdc93102cbd6574f956698993a54bf
2 parents bc2b1f0 + a3789c7 commit cb9764b

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/bitcoin-cli.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ class NetinfoRequestHandler : public BaseRequestHandler
642642
" send Time since last message sent to the peer, in seconds\n"
643643
" recv Time since last message received from the peer, in seconds\n"
644644
" txn Time since last novel transaction received from the peer and accepted into our mempool, in minutes\n"
645-
" \"*\" - the peer requested we not relay transactions to it (relaytxes is false)\n"
645+
" \"*\" - whether we relay transactions to this peer (relaytxes is false)\n"
646646
" blk Time since last novel block passing initial validity checks received from the peer, in minutes\n"
647647
" hb High-bandwidth BIP152 compact block relay\n"
648648
" \".\" (to) - we selected the peer as a high-bandwidth peer\n"

src/net_processing.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,7 @@ struct Peer {
271271

272272
struct TxRelay {
273273
mutable RecursiveMutex m_bloom_filter_mutex;
274-
/** Whether the peer wishes to receive transaction announcements.
275-
*
276-
* This is initially set based on the fRelay flag in the received
277-
* `version` message. If initially set to false, it can only be flipped
278-
* to true if we have offered the peer NODE_BLOOM services and it sends
279-
* us a `filterload` or `filterclear` message. See BIP37. */
274+
/** Whether we relay transactions to this peer. */
280275
bool m_relay_txs GUARDED_BY(m_bloom_filter_mutex){false};
281276
/** A bloom filter for which transactions to announce to the peer. See BIP37. */
282277
std::unique_ptr<CBloomFilter> m_bloom_filter PT_GUARDED_BY(m_bloom_filter_mutex) GUARDED_BY(m_bloom_filter_mutex){nullptr};
@@ -3252,10 +3247,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
32523247
}
32533248
peer->m_starting_height = starting_height;
32543249

3255-
// We only initialize the m_tx_relay data structure if:
3256-
// - this isn't an outbound block-relay-only connection; and
3257-
// - fRelay=true or we're offering NODE_BLOOM to this peer
3258-
// (NODE_BLOOM means that the peer may turn on tx relay later)
3250+
// We only initialize the Peer::TxRelay m_relay_txs data structure if:
3251+
// - this isn't an outbound block-relay-only connection, and
3252+
// - fRelay=true (the peer wishes to receive transaction announcements)
3253+
// or we're offering NODE_BLOOM to this peer. NODE_BLOOM means that
3254+
// the peer may turn on transaction relay later.
32593255
if (!pfrom.IsBlockOnlyConn() &&
32603256
(fRelay || (peer->m_our_services & NODE_BLOOM))) {
32613257
auto* const tx_relay = peer->SetTxRelay();

src/rpc/net.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static RPCHelpMan getpeerinfo()
114114
{
115115
{RPCResult::Type::STR, "SERVICE_NAME", "the service name if it is recognised"}
116116
}},
117-
{RPCResult::Type::BOOL, "relaytxes", /*optional=*/true, "Whether peer has asked us to relay transactions to it"},
117+
{RPCResult::Type::BOOL, "relaytxes", /*optional=*/true, "Whether we relay transactions to this peer"},
118118
{RPCResult::Type::NUM_TIME, "lastsend", "The " + UNIX_EPOCH_TIME + " of the last send"},
119119
{RPCResult::Type::NUM_TIME, "lastrecv", "The " + UNIX_EPOCH_TIME + " of the last receive"},
120120
{RPCResult::Type::NUM_TIME, "last_transaction", "The " + UNIX_EPOCH_TIME + " of the last valid transaction received from this peer"},
@@ -123,9 +123,9 @@ static RPCHelpMan getpeerinfo()
123123
{RPCResult::Type::NUM, "bytesrecv", "The total bytes received"},
124124
{RPCResult::Type::NUM_TIME, "conntime", "The " + UNIX_EPOCH_TIME + " of the connection"},
125125
{RPCResult::Type::NUM, "timeoffset", "The time offset in seconds"},
126-
{RPCResult::Type::NUM, "pingtime", /*optional=*/true, "ping time (if available)"},
127-
{RPCResult::Type::NUM, "minping", /*optional=*/true, "minimum observed ping time (if any at all)"},
128-
{RPCResult::Type::NUM, "pingwait", /*optional=*/true, "ping wait (if non-zero)"},
126+
{RPCResult::Type::NUM, "pingtime", /*optional=*/true, "The last ping time in milliseconds (ms), if any"},
127+
{RPCResult::Type::NUM, "minping", /*optional=*/true, "The minimum observed ping time in milliseconds (ms), if any"},
128+
{RPCResult::Type::NUM, "pingwait", /*optional=*/true, "The duration in milliseconds (ms) of an outstanding ping (if non-zero)"},
129129
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
130130
{RPCResult::Type::STR, "subver", "The string version"},
131131
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
@@ -146,7 +146,7 @@ static RPCHelpMan getpeerinfo()
146146
{
147147
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
148148
}},
149-
{RPCResult::Type::NUM, "minfeefilter", /*optional=*/true, "The minimum fee rate for transactions this peer accepts"},
149+
{RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"},
150150
{RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "",
151151
{
152152
{RPCResult::Type::NUM, "msg", "The total bytes sent aggregated by message type\n"
@@ -200,6 +200,9 @@ static RPCHelpMan getpeerinfo()
200200
ServiceFlags services{fStateStats ? statestats.their_services : ServiceFlags::NODE_NONE};
201201
obj.pushKV("services", strprintf("%016x", services));
202202
obj.pushKV("servicesnames", GetServicesNames(services));
203+
if (fStateStats) {
204+
obj.pushKV("relaytxes", statestats.m_relay_txs);
205+
}
203206
obj.pushKV("lastsend", count_seconds(stats.m_last_send));
204207
obj.pushKV("lastrecv", count_seconds(stats.m_last_recv));
205208
obj.pushKV("last_transaction", count_seconds(stats.m_last_tx_time));
@@ -235,8 +238,6 @@ static RPCHelpMan getpeerinfo()
235238
heights.push_back(height);
236239
}
237240
obj.pushKV("inflight", heights);
238-
obj.pushKV("relaytxes", statestats.m_relay_txs);
239-
obj.pushKV("minfeefilter", ValueFromAmount(statestats.m_fee_filter_received));
240241
obj.pushKV("addr_relay_enabled", statestats.m_addr_relay_enabled);
241242
obj.pushKV("addr_processed", statestats.m_addr_processed);
242243
obj.pushKV("addr_rate_limited", statestats.m_addr_rate_limited);
@@ -246,6 +247,7 @@ static RPCHelpMan getpeerinfo()
246247
permissions.push_back(permission);
247248
}
248249
obj.pushKV("permissions", permissions);
250+
obj.pushKV("minfeefilter", fStateStats ? ValueFromAmount(statestats.m_fee_filter_received) : 0);
249251

250252
UniValue sendPerMsgType(UniValue::VOBJ);
251253
for (const auto& i : stats.mapSendBytesPerMsgType) {

0 commit comments

Comments
 (0)