refactor: use structured bindings for map entries

This commit is contained in:
Lőrinc
2026-08-27 12:25:46 -05:00
parent 21d5d5cb73
commit 74ddf1c0a0
2 changed files with 14 additions and 12 deletions

View File

@@ -293,16 +293,18 @@ static RPCMethod getpeerinfo()
obj.pushKV("minfeefilter", ValueFromAmount(statestats.m_fee_filter_received));
UniValue sendPerMsgType(UniValue::VOBJ);
for (const auto& i : stats.mapSendBytesPerMsgType) {
if (i.second > 0)
sendPerMsgType.pushKVEnd(i.first, i.second);
for (const auto& [message_type, total_bytes] : stats.mapSendBytesPerMsgType) {
if (total_bytes > 0) {
sendPerMsgType.pushKVEnd(message_type, total_bytes);
}
}
obj.pushKV("bytessent_per_msg", std::move(sendPerMsgType));
UniValue recvPerMsgType(UniValue::VOBJ);
for (const auto& i : stats.mapRecvBytesPerMsgType) {
if (i.second > 0)
recvPerMsgType.pushKVEnd(i.first, i.second);
for (const auto& [message_type, total_bytes] : stats.mapRecvBytesPerMsgType) {
if (total_bytes > 0) {
recvPerMsgType.pushKVEnd(message_type, total_bytes);
}
}
obj.pushKV("bytesrecv_per_msg", std::move(recvPerMsgType));
obj.pushKV("connection_type", ConnectionTypeAsString(stats.m_conn_type));

View File

@@ -1164,8 +1164,8 @@ static RPCMethod decodepsbt()
// Unknown data
UniValue unknowns(UniValue::VOBJ);
for (auto entry : psbtx.unknown) {
unknowns.pushKVEnd(HexStr(entry.first), HexStr(entry.second));
for (auto [key, value] : psbtx.unknown) {
unknowns.pushKVEnd(HexStr(key), HexStr(value));
}
result.pushKV("unknown", std::move(unknowns));
@@ -1448,8 +1448,8 @@ static RPCMethod decodepsbt()
// Unknown data
if (input.unknown.size() > 0) {
UniValue unknowns(UniValue::VOBJ);
for (auto entry : input.unknown) {
unknowns.pushKVEnd(HexStr(entry.first), HexStr(entry.second));
for (auto [key, value] : input.unknown) {
unknowns.pushKVEnd(HexStr(key), HexStr(value));
}
in.pushKV("unknown", std::move(unknowns));
}
@@ -1567,8 +1567,8 @@ static RPCMethod decodepsbt()
// Unknown data
if (output.unknown.size() > 0) {
UniValue unknowns(UniValue::VOBJ);
for (auto entry : output.unknown) {
unknowns.pushKVEnd(HexStr(entry.first), HexStr(entry.second));
for (auto [key, value] : output.unknown) {
unknowns.pushKVEnd(HexStr(key), HexStr(value));
}
out.pushKV("unknown", std::move(unknowns));
}