@@ -148,30 +148,27 @@ uint16_t GetListenPort()
148
148
// find 'best' local address for a particular peer
149
149
[[nodiscard]] static bool GetLocal (CService& addr, const CNode& peer)
150
150
{
151
- if (!fListen )
152
- return false ;
151
+ if (!fListen ) return false ;
153
152
154
153
int nBestScore = -1 ;
155
154
int nBestReachability = -1 ;
156
155
{
157
156
LOCK (g_maplocalhost_mutex);
158
- for (const auto & entry : mapLocalHost)
159
- {
157
+ for (const auto & [local_addr, local_service_info] : mapLocalHost) {
160
158
// For privacy reasons, don't advertise our privacy-network address
161
159
// to other networks and don't advertise our other-network address
162
160
// to privacy networks.
163
- const Network our_net{entry. first .GetNetwork ()};
161
+ const Network our_net{local_addr .GetNetwork ()};
164
162
const Network peers_net{peer.ConnectedThroughNetwork ()};
165
163
if (our_net != peers_net &&
166
164
(our_net == NET_ONION || our_net == NET_I2P ||
167
165
peers_net == NET_ONION || peers_net == NET_I2P)) {
168
166
continue ;
169
167
}
170
- int nScore = entry.second .nScore ;
171
- int nReachability = entry.first .GetReachabilityFrom (peer.addr );
172
- if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore))
173
- {
174
- addr = CService (entry.first , entry.second .nPort );
168
+ const int nScore{local_service_info.nScore };
169
+ const int nReachability{local_addr.GetReachabilityFrom (peer.addr )};
170
+ if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore)) {
171
+ addr = CService{local_addr, local_service_info.nPort };
175
172
nBestReachability = nReachability;
176
173
nBestScore = nScore;
177
174
}
0 commit comments