From 74ddf1c0a0ef8447686f59044b2fc2ee8d78c0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Thu, 27 Aug 2026 12:25:46 -0500 Subject: [PATCH] refactor: use structured bindings for map entries --- src/rpc/net.cpp | 14 ++++++++------ src/rpc/rawtransaction.cpp | 12 ++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index b4d0300c3c9..def4a50088c 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -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)); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 16b2e0be904..67215f038e8 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -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)); }