@@ -112,9 +112,9 @@ static const uint64_t RANDOMIZER_ID_ADDRCACHE = 0x1cf2e4ddd306dda9ULL; // SHA256
112
112
//
113
113
bool fDiscover = true ;
114
114
bool 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 ) = {};
118
118
std::string strSubVersion;
119
119
120
120
void CConnman::AddAddrFetch (const std::string& strDest)
@@ -137,7 +137,7 @@ bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
137
137
int nBestScore = -1 ;
138
138
int nBestReachability = -1 ;
139
139
{
140
- LOCK (cs_mapLocalHost );
140
+ LOCK (g_maplocalhost_mutex );
141
141
for (const auto & entry : mapLocalHost)
142
142
{
143
143
int nScore = entry.second .nScore ;
@@ -193,7 +193,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
193
193
194
194
static int GetnScore (const CService& addr)
195
195
{
196
- LOCK (cs_mapLocalHost );
196
+ LOCK (g_maplocalhost_mutex );
197
197
const auto it = mapLocalHost.find (addr);
198
198
return (it != mapLocalHost.end ()) ? it->second .nScore : 0 ;
199
199
}
@@ -264,7 +264,7 @@ bool AddLocal(const CService& addr_, int nScore)
264
264
LogPrintf (" AddLocal(%s,%i)\n " , addr.ToString (), nScore);
265
265
266
266
{
267
- LOCK (cs_mapLocalHost );
267
+ LOCK (g_maplocalhost_mutex );
268
268
const auto [it, is_newly_added] = mapLocalHost.emplace (addr, LocalServiceInfo ());
269
269
LocalServiceInfo &info = it->second ;
270
270
if (is_newly_added || nScore >= info.nScore ) {
@@ -283,7 +283,7 @@ bool AddLocal(const CNetAddr &addr, int nScore)
283
283
284
284
void RemoveLocal (const CService& addr)
285
285
{
286
- LOCK (cs_mapLocalHost );
286
+ LOCK (g_maplocalhost_mutex );
287
287
LogPrintf (" RemoveLocal(%s)\n " , addr.ToString ());
288
288
mapLocalHost.erase (addr);
289
289
}
@@ -292,13 +292,13 @@ void SetReachable(enum Network net, bool reachable)
292
292
{
293
293
if (net == NET_UNROUTABLE || net == NET_INTERNAL)
294
294
return ;
295
- LOCK (cs_mapLocalHost );
295
+ LOCK (g_maplocalhost_mutex );
296
296
vfLimited[net] = !reachable;
297
297
}
298
298
299
299
bool IsReachable (enum Network net)
300
300
{
301
- LOCK (cs_mapLocalHost );
301
+ LOCK (g_maplocalhost_mutex );
302
302
return !vfLimited[net];
303
303
}
304
304
@@ -310,7 +310,7 @@ bool IsReachable(const CNetAddr &addr)
310
310
/* * vote for a local address */
311
311
bool SeenLocal (const CService& addr)
312
312
{
313
- LOCK (cs_mapLocalHost );
313
+ LOCK (g_maplocalhost_mutex );
314
314
const auto it = mapLocalHost.find (addr);
315
315
if (it == mapLocalHost.end ()) return false ;
316
316
++it->second .nScore ;
@@ -321,7 +321,7 @@ bool SeenLocal(const CService& addr)
321
321
/* * check whether a given address is potentially local */
322
322
bool IsLocal (const CService& addr)
323
323
{
324
- LOCK (cs_mapLocalHost );
324
+ LOCK (g_maplocalhost_mutex );
325
325
return mapLocalHost.count (addr) > 0 ;
326
326
}
327
327
0 commit comments