@@ -112,9 +112,9 @@ static const uint64_t RANDOMIZER_ID_ADDRCACHE = 0x1cf2e4ddd306dda9ULL; // SHA256
112112//
113113bool fDiscover = true ;
114114bool fListen = true ;
115- RecursiveMutex cs_mapLocalHost ;
116- std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY (cs_mapLocalHost );
117- static bool vfLimited[NET_MAX] GUARDED_BY(cs_mapLocalHost ) = {};
115+ RecursiveMutex g_maplocalhost_mutex ;
116+ std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY (g_maplocalhost_mutex );
117+ static bool vfLimited[NET_MAX] GUARDED_BY(g_maplocalhost_mutex ) = {};
118118std::string strSubVersion;
119119
120120void CConnman::AddAddrFetch (const std::string& strDest)
@@ -137,7 +137,7 @@ bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
137137 int nBestScore = -1 ;
138138 int nBestReachability = -1 ;
139139 {
140- LOCK (cs_mapLocalHost );
140+ LOCK (g_maplocalhost_mutex );
141141 for (const auto & entry : mapLocalHost)
142142 {
143143 int nScore = entry.second .nScore ;
@@ -193,7 +193,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
193193
194194static int GetnScore (const CService& addr)
195195{
196- LOCK (cs_mapLocalHost );
196+ LOCK (g_maplocalhost_mutex );
197197 const auto it = mapLocalHost.find (addr);
198198 return (it != mapLocalHost.end ()) ? it->second .nScore : 0 ;
199199}
@@ -264,7 +264,7 @@ bool AddLocal(const CService& addr_, int nScore)
264264 LogPrintf (" AddLocal(%s,%i)\n " , addr.ToString (), nScore);
265265
266266 {
267- LOCK (cs_mapLocalHost );
267+ LOCK (g_maplocalhost_mutex );
268268 const auto [it, is_newly_added] = mapLocalHost.emplace (addr, LocalServiceInfo ());
269269 LocalServiceInfo &info = it->second ;
270270 if (is_newly_added || nScore >= info.nScore ) {
@@ -283,7 +283,7 @@ bool AddLocal(const CNetAddr &addr, int nScore)
283283
284284void RemoveLocal (const CService& addr)
285285{
286- LOCK (cs_mapLocalHost );
286+ LOCK (g_maplocalhost_mutex );
287287 LogPrintf (" RemoveLocal(%s)\n " , addr.ToString ());
288288 mapLocalHost.erase (addr);
289289}
@@ -292,13 +292,13 @@ void SetReachable(enum Network net, bool reachable)
292292{
293293 if (net == NET_UNROUTABLE || net == NET_INTERNAL)
294294 return ;
295- LOCK (cs_mapLocalHost );
295+ LOCK (g_maplocalhost_mutex );
296296 vfLimited[net] = !reachable;
297297}
298298
299299bool IsReachable (enum Network net)
300300{
301- LOCK (cs_mapLocalHost );
301+ LOCK (g_maplocalhost_mutex );
302302 return !vfLimited[net];
303303}
304304
@@ -310,7 +310,7 @@ bool IsReachable(const CNetAddr &addr)
310310/* * vote for a local address */
311311bool SeenLocal (const CService& addr)
312312{
313- LOCK (cs_mapLocalHost );
313+ LOCK (g_maplocalhost_mutex );
314314 const auto it = mapLocalHost.find (addr);
315315 if (it == mapLocalHost.end ()) return false ;
316316 ++it->second .nScore ;
@@ -321,7 +321,7 @@ bool SeenLocal(const CService& addr)
321321/* * check whether a given address is potentially local */
322322bool IsLocal (const CService& addr)
323323{
324- LOCK (cs_mapLocalHost );
324+ LOCK (g_maplocalhost_mutex );
325325 return mapLocalHost.count (addr) > 0 ;
326326}
327327
0 commit comments