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 Fuzzbawls committed Jun 23, 2020
1 parent fcb732b commit fd7bab0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,14 +921,14 @@ static void AcceptConnection(const ListenSocket& hListenSocket) {
return;
}

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

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

0 comments on commit fd7bab0

Please sign in to comment.