mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Drop IsLimited in favor of IsReachable
These two methods have had the same meaning, but inverted, since
110b62f069. Having one name for a single
concept simplifies the code.
This commit is contained in:
34
src/net.cpp
34
src/net.cpp
@@ -183,7 +183,7 @@ bool IsPeerAddrLocalGood(CNode *pnode)
|
||||
{
|
||||
CService addrLocal = pnode->GetAddrLocal();
|
||||
return fDiscover && pnode->addr.IsRoutable() && addrLocal.IsRoutable() &&
|
||||
!IsLimited(addrLocal.GetNetwork());
|
||||
IsReachable(addrLocal.GetNetwork());
|
||||
}
|
||||
|
||||
// pushes our own address to a peer
|
||||
@@ -222,7 +222,7 @@ bool AddLocal(const CService& addr, int nScore)
|
||||
if (!fDiscover && nScore < LOCAL_MANUAL)
|
||||
return false;
|
||||
|
||||
if (IsLimited(addr))
|
||||
if (!IsReachable(addr))
|
||||
return false;
|
||||
|
||||
LogPrintf("AddLocal(%s,%i)\n", addr.ToString(), nScore);
|
||||
@@ -252,24 +252,23 @@ void RemoveLocal(const CService& addr)
|
||||
mapLocalHost.erase(addr);
|
||||
}
|
||||
|
||||
/** Make a particular network entirely off-limits (no automatic connects to it) */
|
||||
void SetLimited(enum Network net, bool fLimited)
|
||||
void SetReachable(enum Network net, bool reachable)
|
||||
{
|
||||
if (net == NET_UNROUTABLE || net == NET_INTERNAL)
|
||||
return;
|
||||
LOCK(cs_mapLocalHost);
|
||||
vfLimited[net] = fLimited;
|
||||
vfLimited[net] = !reachable;
|
||||
}
|
||||
|
||||
bool IsLimited(enum Network net)
|
||||
bool IsReachable(enum Network net)
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
return vfLimited[net];
|
||||
return !vfLimited[net];
|
||||
}
|
||||
|
||||
bool IsLimited(const CNetAddr &addr)
|
||||
bool IsReachable(const CNetAddr &addr)
|
||||
{
|
||||
return IsLimited(addr.GetNetwork());
|
||||
return IsReachable(addr.GetNetwork());
|
||||
}
|
||||
|
||||
/** vote for a local address */
|
||||
@@ -292,19 +291,6 @@ bool IsLocal(const CService& addr)
|
||||
return mapLocalHost.count(addr) > 0;
|
||||
}
|
||||
|
||||
/** check whether a given network is one we can probably connect to */
|
||||
bool IsReachable(enum Network net)
|
||||
{
|
||||
return !IsLimited(net);
|
||||
}
|
||||
|
||||
/** check whether a given address is in a network we can probably connect to */
|
||||
bool IsReachable(const CNetAddr& addr)
|
||||
{
|
||||
return IsReachable(addr.GetNetwork());
|
||||
}
|
||||
|
||||
|
||||
CNode* CConnman::FindNode(const CNetAddr& ip)
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
@@ -1965,7 +1951,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
||||
if (nTries > 100)
|
||||
break;
|
||||
|
||||
if (IsLimited(addr))
|
||||
if (!IsReachable(addr))
|
||||
continue;
|
||||
|
||||
// only consider very recently tried nodes after 30 failed attempts
|
||||
@@ -2327,7 +2313,7 @@ NodeId CConnman::GetNewNodeId()
|
||||
|
||||
|
||||
bool CConnman::Bind(const CService &addr, unsigned int flags) {
|
||||
if (!(flags & BF_EXPLICIT) && IsLimited(addr))
|
||||
if (!(flags & BF_EXPLICIT) && !IsReachable(addr))
|
||||
return false;
|
||||
std::string strError;
|
||||
if (!BindListenPort(addr, strError, (flags & BF_WHITELIST) != 0)) {
|
||||
|
||||
Reference in New Issue
Block a user