@@ -148,30 +148,27 @@ uint16_t GetListenPort()
148148// find 'best' local address for a particular peer
149149[[nodiscard]] static bool GetLocal (CService& addr, const CNode& peer)
150150{
151- if (!fListen )
152- return false ;
151+ if (!fListen ) return false ;
153152
154153 int nBestScore = -1 ;
155154 int nBestReachability = -1 ;
156155 {
157156 LOCK (g_maplocalhost_mutex);
158- for (const auto & entry : mapLocalHost)
159- {
157+ for (const auto & [local_addr, local_service_info] : mapLocalHost) {
160158 // For privacy reasons, don't advertise our privacy-network address
161159 // to other networks and don't advertise our other-network address
162160 // to privacy networks.
163- const Network our_net{entry. first .GetNetwork ()};
161+ const Network our_net{local_addr .GetNetwork ()};
164162 const Network peers_net{peer.ConnectedThroughNetwork ()};
165163 if (our_net != peers_net &&
166164 (our_net == NET_ONION || our_net == NET_I2P ||
167165 peers_net == NET_ONION || peers_net == NET_I2P)) {
168166 continue ;
169167 }
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 };
175172 nBestReachability = nReachability;
176173 nBestScore = nScore;
177174 }
0 commit comments