Skip to content

Commit a7da140

Browse files
committed
scripted-diff: rename cs_mapLocalHost -> g_maplocalhost_mutex
-BEGIN VERIFY SCRIPT- s() { sed -i 's/cs_mapLocalHost/g_maplocalhost_mutex/g' $1; } s src/net.cpp s src/net.h s src/rpc/net.cpp s src/test/net_tests.cpp -END VERIFY SCRIPT-
1 parent 5c3bfee commit a7da140

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/net.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ static const uint64_t RANDOMIZER_ID_ADDRCACHE = 0x1cf2e4ddd306dda9ULL; // SHA256
112112
//
113113
bool fDiscover = true;
114114
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) = {};
118118
std::string strSubVersion;
119119

120120
void 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

194194
static 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

284284
void 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

299299
bool 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 */
311311
bool 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 */
322322
bool IsLocal(const CService& addr)
323323
{
324-
LOCK(cs_mapLocalHost);
324+
LOCK(g_maplocalhost_mutex);
325325
return mapLocalHost.count(addr) > 0;
326326
}
327327

src/net.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ struct LocalServiceInfo {
230230
uint16_t nPort;
231231
};
232232

233-
extern RecursiveMutex cs_mapLocalHost;
234-
extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY(cs_mapLocalHost);
233+
extern RecursiveMutex g_maplocalhost_mutex;
234+
extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY(g_maplocalhost_mutex);
235235

236236
extern const std::string NET_MESSAGE_COMMAND_OTHER;
237237
typedef std::map<std::string, uint64_t> mapMsgCmdSize; //command, total bytes

src/rpc/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ static RPCHelpMan getnetworkinfo()
648648
obj.pushKV("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()));
649649
UniValue localAddresses(UniValue::VARR);
650650
{
651-
LOCK(cs_mapLocalHost);
651+
LOCK(g_maplocalhost_mutex);
652652
for (const std::pair<const CNetAddr, LocalServiceInfo> &item : mapLocalHost)
653653
{
654654
UniValue rec(UniValue::VOBJ);

src/test/net_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ BOOST_AUTO_TEST_CASE(ipv4_peer_with_ipv6_addrMe_test)
593593
// that a normal IPv4 address is among the entries, but if this address is
594594
// !IsRoutable the undefined behavior is easier to trigger deterministically
595595
{
596-
LOCK(cs_mapLocalHost);
596+
LOCK(g_maplocalhost_mutex);
597597
in_addr ipv4AddrLocal;
598598
ipv4AddrLocal.s_addr = 0x0100007f;
599599
CNetAddr addr = CNetAddr(ipv4AddrLocal);

0 commit comments

Comments
 (0)