Skip to content

Commit 1dc0e4b

Browse files
committed
rpc: remove optional from fStateStats fields
These are no-longer optional after bitcoin#26515, so remove the documentation, and no-op fStateStats checks.
1 parent 8ab1923 commit 1dc0e4b

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

src/rpc/net.cpp

+24-28
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 we relay transactions to this peer"},
117+
{RPCResult::Type::BOOL, "relaytxes", "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"},
@@ -131,17 +131,17 @@ static RPCHelpMan getpeerinfo()
131131
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
132132
{RPCResult::Type::BOOL, "bip152_hb_to", "Whether we selected peer as (compact blocks) high-bandwidth peer"},
133133
{RPCResult::Type::BOOL, "bip152_hb_from", "Whether peer selected us as (compact blocks) high-bandwidth peer"},
134-
{RPCResult::Type::NUM, "startingheight", /*optional=*/true, "The starting height (block) of the peer"},
135-
{RPCResult::Type::NUM, "presynced_headers", /*optional=*/true, "The current height of header pre-synchronization with this peer, or -1 if no low-work sync is in progress"},
136-
{RPCResult::Type::NUM, "synced_headers", /*optional=*/true, "The last header we have in common with this peer"},
137-
{RPCResult::Type::NUM, "synced_blocks", /*optional=*/true, "The last block we have in common with this peer"},
138-
{RPCResult::Type::ARR, "inflight", /*optional=*/true, "",
134+
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
135+
{RPCResult::Type::NUM, "presynced_headers", "The current height of header pre-synchronization with this peer, or -1 if no low-work sync is in progress"},
136+
{RPCResult::Type::NUM, "synced_headers", "The last header we have in common with this peer"},
137+
{RPCResult::Type::NUM, "synced_blocks", "The last block we have in common with this peer"},
138+
{RPCResult::Type::ARR, "inflight", "",
139139
{
140140
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
141141
}},
142-
{RPCResult::Type::BOOL, "addr_relay_enabled", /*optional=*/true, "Whether we participate in address relay with this peer"},
143-
{RPCResult::Type::NUM, "addr_processed", /*optional=*/true, "The total number of addresses processed, excluding those dropped due to rate limiting"},
144-
{RPCResult::Type::NUM, "addr_rate_limited", /*optional=*/true, "The total number of addresses dropped due to rate limiting"},
142+
{RPCResult::Type::BOOL, "addr_relay_enabled", "Whether we participate in address relay with this peer"},
143+
{RPCResult::Type::NUM, "addr_processed", "The total number of addresses processed, excluding those dropped due to rate limiting"},
144+
{RPCResult::Type::NUM, "addr_rate_limited", "The total number of addresses dropped due to rate limiting"},
145145
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
146146
{
147147
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
@@ -205,12 +205,10 @@ static RPCHelpMan getpeerinfo()
205205
if (stats.m_mapped_as != 0) {
206206
obj.pushKV("mapped_as", uint64_t(stats.m_mapped_as));
207207
}
208-
ServiceFlags services{fStateStats ? statestats.their_services : ServiceFlags::NODE_NONE};
208+
ServiceFlags services{statestats.their_services};
209209
obj.pushKV("services", strprintf("%016x", services));
210210
obj.pushKV("servicesnames", GetServicesNames(services));
211-
if (fStateStats) {
212-
obj.pushKV("relaytxes", statestats.m_relay_txs);
213-
}
211+
obj.pushKV("relaytxes", statestats.m_relay_txs);
214212
obj.pushKV("lastsend", count_seconds(stats.m_last_send));
215213
obj.pushKV("lastrecv", count_seconds(stats.m_last_recv));
216214
obj.pushKV("last_transaction", count_seconds(stats.m_last_tx_time));
@@ -225,7 +223,7 @@ static RPCHelpMan getpeerinfo()
225223
if (stats.m_min_ping_time < std::chrono::microseconds::max()) {
226224
obj.pushKV("minping", Ticks<SecondsDouble>(stats.m_min_ping_time));
227225
}
228-
if (fStateStats && statestats.m_ping_wait > 0s) {
226+
if (statestats.m_ping_wait > 0s) {
229227
obj.pushKV("pingwait", Ticks<SecondsDouble>(statestats.m_ping_wait));
230228
}
231229
obj.pushKV("version", stats.nVersion);
@@ -236,26 +234,24 @@ static RPCHelpMan getpeerinfo()
236234
obj.pushKV("inbound", stats.fInbound);
237235
obj.pushKV("bip152_hb_to", stats.m_bip152_highbandwidth_to);
238236
obj.pushKV("bip152_hb_from", stats.m_bip152_highbandwidth_from);
239-
if (fStateStats) {
240-
obj.pushKV("startingheight", statestats.m_starting_height);
241-
obj.pushKV("presynced_headers", statestats.presync_height);
242-
obj.pushKV("synced_headers", statestats.nSyncHeight);
243-
obj.pushKV("synced_blocks", statestats.nCommonHeight);
244-
UniValue heights(UniValue::VARR);
245-
for (const int height : statestats.vHeightInFlight) {
246-
heights.push_back(height);
247-
}
248-
obj.pushKV("inflight", heights);
249-
obj.pushKV("addr_relay_enabled", statestats.m_addr_relay_enabled);
250-
obj.pushKV("addr_processed", statestats.m_addr_processed);
251-
obj.pushKV("addr_rate_limited", statestats.m_addr_rate_limited);
237+
obj.pushKV("startingheight", statestats.m_starting_height);
238+
obj.pushKV("presynced_headers", statestats.presync_height);
239+
obj.pushKV("synced_headers", statestats.nSyncHeight);
240+
obj.pushKV("synced_blocks", statestats.nCommonHeight);
241+
UniValue heights(UniValue::VARR);
242+
for (const int height : statestats.vHeightInFlight) {
243+
heights.push_back(height);
252244
}
245+
obj.pushKV("inflight", heights);
246+
obj.pushKV("addr_relay_enabled", statestats.m_addr_relay_enabled);
247+
obj.pushKV("addr_processed", statestats.m_addr_processed);
248+
obj.pushKV("addr_rate_limited", statestats.m_addr_rate_limited);
253249
UniValue permissions(UniValue::VARR);
254250
for (const auto& permission : NetPermissions::ToStrings(stats.m_permission_flags)) {
255251
permissions.push_back(permission);
256252
}
257253
obj.pushKV("permissions", permissions);
258-
obj.pushKV("minfeefilter", fStateStats ? ValueFromAmount(statestats.m_fee_filter_received) : 0);
254+
obj.pushKV("minfeefilter", ValueFromAmount(statestats.m_fee_filter_received));
259255

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

0 commit comments

Comments
 (0)