diff -uNr a/bitcoin/src/net.cpp b/bitcoin/src/net.cpp --- a/bitcoin/src/net.cpp 0124234fe388c52595cd67f193728e2fe9a8e5025418df317fe4e4e447572c54fd205578695d61fd7f8d42efe141ee7da9c6435edf2063ffc5ed81fa6d3c64ab +++ b/bitcoin/src/net.cpp af873d2709b3b975201a350582e23855d08663d8f18908f1fcf0d1377a5e64d20c34e1717d9937c26c73e71bf91bd3469bdd82085d12b4f2a4991fc47bb4ed3e @@ -13,8 +13,6 @@ using namespace std; using namespace boost; -static const int MAX_OUTBOUND_CONNECTIONS = 8; - void ThreadMessageHandler2(void* parg); void ThreadSocketHandler2(void* parg); void ThreadOpenConnections2(void* parg); @@ -741,7 +739,7 @@ if (WSAGetLastError() != WSAEWOULDBLOCK) printf("socket error accept failed: %d\n", WSAGetLastError()); } - else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS) + else if (nInbound >= GetArg("-maxconnections", 125)) { closesocket(hSocket); } @@ -830,6 +828,9 @@ // if (pnode->hSocket == INVALID_SOCKET) continue; + if ((nTimeBestReceived - GetTime()) > 20 * 60) { + pnode->PushGetBlocks(pindexBest, uint256(0)); + } if (FD_ISSET(pnode->hSocket, &fdsetSend)) { TRY_CRITICAL_BLOCK(pnode->cs_vSend) @@ -974,8 +975,7 @@ BOOST_FOREACH(CNode* pnode, vNodes) if (!pnode->fInbound) nOutbound++; - int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS; - nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125)); + int nMaxOutboundConnections = GetArg("-maxconnections", 125); if (nOutbound < nMaxOutboundConnections) break; vnThreadsRunning[1]--; @@ -991,13 +991,6 @@ CAddress addrConnect; int64 nBest = INT64_MIN; - // Only connect to one address per a.b.?.? range. - // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. - set setConnected; - CRITICAL_BLOCK(cs_vNodes) - BOOST_FOREACH(CNode* pnode, vNodes) - setConnected.insert(pnode->addr.ip & 0x0000ffff); - int64 nANow = GetAdjustedTime(); CRITICAL_BLOCK(cs_mapAddresses) @@ -1005,7 +998,7 @@ BOOST_FOREACH(const PAIRTYPE(vector, CAddress)& item, mapAddresses) { const CAddress& addr = item.second; - if (!addr.IsIPv4() || !addr.IsValid() || setConnected.count(addr.ip & 0x0000ffff)) + if (!addr.IsIPv4() || !addr.IsValid()) continue; int64 nSinceLastSeen = nANow - addr.nTime; int64 nSinceLastTry = nANow - addr.nLastTry;