Skip to content

Commit

Permalink
[p2p] No delay in adding fixed seeds if -dnsseed=0 and peers.dat is e…
Browse files Browse the repository at this point in the history
…mpty
  • Loading branch information
dhruv committed Sep 5, 2020
1 parent 3ba25e3 commit efdbbff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/net.cpp
Expand Up @@ -1845,15 +1845,18 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
// Note that we only do this if we started with an empty peers.dat,
// (in which case we will query DNS seeds immediately) *and* the DNS
// seeds have not returned any results.
if (addrman.size() == 0 && (GetTime() - nStart > 60)) {
static bool done = false;
if (!done) {
bool dnsseed = gArgs.GetBoolArg("-dnsseed", DEFAULT_DNSSEED);
if (addrman.size() == 0 &&
((GetTime() - nStart > 60) || !dnsseed)) {
if (!dnsseed) {
LogPrintf("Adding fixed seed nodes as -dnsseed is disabled.\n");
} else {
LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n");
CNetAddr local;
local.SetInternal("fixedseeds");
addrman.Add(convertSeed6(Params().FixedSeeds()), local);
done = true;
}

CNetAddr local;
local.SetInternal("fixedseeds");
addrman.Add(convertSeed6(Params().FixedSeeds()), local);
}

//
Expand Down Expand Up @@ -2406,7 +2409,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
// Send and receive from sockets, accept connections
threadSocketHandler = std::thread(&TraceThread<std::function<void()> >, "net", std::function<void()>(std::bind(&CConnman::ThreadSocketHandler, this)));

if (!gArgs.GetBoolArg("-dnsseed", true))
if (!gArgs.GetBoolArg("-dnsseed", DEFAULT_DNSSEED))
LogPrintf("DNS seeding disabled\n");
else
threadDNSAddressSeed = std::thread(&TraceThread<std::function<void()> >, "dnsseed", std::function<void()>(std::bind(&CConnman::ThreadDNSAddressSeed, this)));
Expand Down
1 change: 1 addition & 0 deletions src/net.h
Expand Up @@ -85,6 +85,7 @@ static const bool DEFAULT_BLOCKSONLY = false;
static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60;

static const bool DEFAULT_FORCEDNSSEED = false;
static const bool DEFAULT_DNSSEED = true;
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;

Expand Down

0 comments on commit efdbbff

Please sign in to comment.