Merge pull request 'optimized IsBanned' (#152) from jahway603/hush3:dev into dev
Reviewed-on: https://git.hush.is/hush/hush3/pulls/152
This commit is contained in:
14
src/net.cpp
14
src/net.cpp
@@ -546,8 +546,6 @@ void CNode::ClearBanned()
|
||||
}
|
||||
|
||||
bool CNode::IsBanned(CNetAddr ip)
|
||||
{
|
||||
bool fResult = false;
|
||||
{
|
||||
LOCK(cs_setBanned);
|
||||
for (std::map<CSubNet, int64_t>::iterator it = setBanned.begin(); it != setBanned.end(); it++)
|
||||
@@ -556,15 +554,12 @@ bool CNode::IsBanned(CNetAddr ip)
|
||||
int64_t t = (*it).second;
|
||||
|
||||
if(subNet.Match(ip) && GetTime() < t)
|
||||
fResult = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return fResult;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CNode::IsBanned(CSubNet subnet)
|
||||
{
|
||||
bool fResult = false;
|
||||
{
|
||||
LOCK(cs_setBanned);
|
||||
std::map<CSubNet, int64_t>::iterator i = setBanned.find(subnet);
|
||||
@@ -572,10 +567,9 @@ bool CNode::IsBanned(CSubNet subnet)
|
||||
{
|
||||
int64_t t = (*i).second;
|
||||
if (GetTime() < t)
|
||||
fResult = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return fResult;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CNode::Ban(const CNetAddr& addr, int64_t bantimeoffset, bool sinceUnixEpoch) {
|
||||
|
||||
Reference in New Issue
Block a user