Skip to content

Commit

Permalink
Refactor: Move failure conditions to the top of AcceptConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
pstratem authored and defuse committed Aug 16, 2016
1 parent 1200501 commit bd80ec0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,23 +706,23 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
return;
}

if (nInbound >= nMaxInbound)
if (CNode::IsBanned(addr) && !whitelisted)
{
LogPrint("net", "connection from %s dropped (full)\n", addr.ToString());
LogPrintf("connection from %s dropped (banned)\n", addr.ToString());
CloseSocket(hSocket);
return;
}

if (!whitelisted && (nInbound >= (nMaxInbound - nWhiteConnections)))
if (nInbound >= nMaxInbound)
{
LogPrint("net", "connection from %s dropped (non-whitelisted)\n", addr.ToString());
LogPrint("net", "connection from %s dropped (full)\n", addr.ToString());
CloseSocket(hSocket);
return;
}

if (CNode::IsBanned(addr) && !whitelisted)
if (!whitelisted && (nInbound >= (nMaxInbound - nWhiteConnections)))
{
LogPrintf("connection from %s dropped (banned)\n", addr.ToString());
LogPrint("net", "connection from %s dropped (non-whitelisted)\n", addr.ToString());
CloseSocket(hSocket);
return;
}
Expand Down

0 comments on commit bd80ec0

Please sign in to comment.