Stay connected to seed nodes; disconnecting causes problems if you are trying to make the initial blockchain download.

This commit is contained in:
Gavin Andresen 2011-09-02 12:25:25 -04:00
parent c591cc50eb
commit b53e277ba1

View file

@ -1349,7 +1349,6 @@ void ThreadOpenConnections2(void* parg)
CRITICAL_BLOCK(cs_mapAddresses) CRITICAL_BLOCK(cs_mapAddresses)
{ {
// Add seed nodes if IRC isn't working // Add seed nodes if IRC isn't working
static bool fSeedUsed;
bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); bool fTOR = (fUseProxy && addrProxy.port == htons(9050));
if (mapAddresses.empty() && (GetTime() - nStart > 60 || fTOR) && !fTestNet) if (mapAddresses.empty() && (GetTime() - nStart > 60 || fTOR) && !fTestNet)
{ {
@ -1365,35 +1364,6 @@ void ThreadOpenConnections2(void* parg)
addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek; addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek;
AddAddress(addr); AddAddress(addr);
} }
fSeedUsed = true;
}
if (fSeedUsed && mapAddresses.size() > ARRAYLEN(pnSeed) + 100)
{
// Disconnect seed nodes
set<unsigned int> setSeed(pnSeed, pnSeed + ARRAYLEN(pnSeed));
static int64 nSeedDisconnected;
if (nSeedDisconnected == 0)
{
nSeedDisconnected = GetTime();
CRITICAL_BLOCK(cs_vNodes)
BOOST_FOREACH(CNode* pnode, vNodes)
if (setSeed.count(pnode->addr.ip))
pnode->fDisconnect = true;
}
// Keep setting timestamps to 0 so they won't reconnect
if (GetTime() - nSeedDisconnected < 60 * 60)
{
BOOST_FOREACH(PAIRTYPE(const vector<unsigned char>, CAddress)& item, mapAddresses)
{
if (setSeed.count(item.second.ip) && item.second.nTime != 0)
{
item.second.nTime = 0;
CAddrDB().WriteAddress(item.second);
}
}
}
} }
} }