Skip to content

Commit 61156de

Browse files
committed
Merge bitcoin#542: [Network] Remove vfReachable and modify IsReachable to only use vfLimited.
38ed737 Remove vfReachable and modify IsReachable to only use vfLimited. (Patrick Strateman) Tree-SHA512: 8aa61f9abd8356522f3ba71b35497aac07e10333a39ff4b98bb635d1246e6b1be6b0ee0b236944fbfaa558af0e6c0cc219e540eacb2232bc05db393e4a72b088
2 parents 21f7772 + 38ed737 commit 61156de

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

src/init.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12221222
// -proxy sets a proxy for all outgoing network traffic
12231223
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
12241224
std::string proxyArg = GetArg("-proxy", "");
1225+
SetLimited(NET_TOR);
12251226
if (proxyArg != "" && proxyArg != "0") {
12261227
CService proxyAddr;
12271228
if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) {
@@ -1236,7 +1237,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12361237
SetProxy(NET_IPV6, addrProxy);
12371238
SetProxy(NET_TOR, addrProxy);
12381239
SetNameProxy(addrProxy);
1239-
SetReachable(NET_TOR); // by default, -proxy sets onion as reachable, unless -noonion later
1240+
SetLimited(NET_TOR, false); // by default, -proxy sets onion as reachable, unless -noonion later
12401241
}
12411242

12421243
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
@@ -1245,7 +1246,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12451246
std::string onionArg = GetArg("-onion", "");
12461247
if (onionArg != "") {
12471248
if (onionArg == "0") { // Handle -noonion/-onion=0
1248-
SetReachable(NET_TOR, false); // set onions as unreachable
1249+
SetLimited(NET_TOR); // set onions as unreachable
12491250
} else {
12501251
CService onionProxy;
12511252
if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) {
@@ -1255,7 +1256,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12551256
if (!addrOnion.IsValid())
12561257
return InitError(strprintf(_("Invalid -onion address or hostname: '%s'"), onionArg));
12571258
SetProxy(NET_TOR, addrOnion);
1258-
SetReachable(NET_TOR);
1259+
SetLimited(NET_TOR, false);
12591260
}
12601261
}
12611262

src/net.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ bool fListen = true;
7878
uint64_t nLocalServices = NODE_NETWORK;
7979
CCriticalSection cs_mapLocalHost;
8080
map<CNetAddr, LocalServiceInfo> mapLocalHost;
81-
static bool vfReachable[NET_MAX] = {};
8281
static bool vfLimited[NET_MAX] = {};
8382
static CNode* pnodeLocalHost = NULL;
8483
uint64_t nLocalHostNonce = 0;
@@ -238,14 +237,6 @@ void AdvertizeLocal(CNode* pnode)
238237
}
239238
}
240239

241-
void SetReachable(enum Network net, bool fFlag)
242-
{
243-
LOCK(cs_mapLocalHost);
244-
vfReachable[net] = fFlag;
245-
if (net == NET_IPV6 && fFlag)
246-
vfReachable[NET_IPV4] = true;
247-
}
248-
249240
// learn a new local address
250241
bool AddLocal(const CService& addr, int nScore)
251242
{
@@ -268,7 +259,6 @@ bool AddLocal(const CService& addr, int nScore)
268259
info.nScore = nScore + (fAlready ? 1 : 0);
269260
info.nPort = addr.GetPort();
270261
}
271-
SetReachable(addr.GetNetwork());
272262
}
273263

274264
return true;
@@ -331,7 +321,7 @@ bool IsLocal(const CService& addr)
331321
bool IsReachable(enum Network net)
332322
{
333323
LOCK(cs_mapLocalHost);
334-
return vfReachable[net] && !vfLimited[net];
324+
return !vfLimited[net];
335325
}
336326

337327
/** check whether a given address is in a network we can probably connect to */

src/net.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ bool IsLocal(const CService& addr);
119119
bool GetLocal(CService& addr, const CNetAddr* paddrPeer = NULL);
120120
bool IsReachable(enum Network net);
121121
bool IsReachable(const CNetAddr& addr);
122-
void SetReachable(enum Network net, bool fFlag = true);
123122
CAddress GetLocalAddress(const CNetAddr* paddrPeer = NULL);
124123

125124

0 commit comments

Comments
 (0)