Skip to content

Commit

Permalink
net: split up addresses/ban dumps in preparation for moving them
Browse files Browse the repository at this point in the history
  • Loading branch information
theuni authored and dongcarl committed Jan 16, 2019
1 parent 136bd79 commit 83c1ea2
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@

#include <math.h>

// Dump addresses to peers.dat and banlist.dat every 15 minutes (900s)
#define DUMP_ADDRESSES_INTERVAL 900
// Dump addresses to peers.dat every 15 minutes (900s)
static constexpr int DUMP_PEERS_INTERVAL = 15 * 60;

// Dump addresses to banlist.dat every 15 minutes (900s)
static constexpr int DUMP_BANS_INTERVAL = 60 * 15;

// We add a random period time (0 to 1 seconds) to feeler connections to prevent synchronization.
#define FEELER_SLEEP_WINDOW 1
Expand Down Expand Up @@ -1768,12 +1771,6 @@ void CConnman::DumpAddresses()
addrman.size(), GetTimeMillis() - nStart);
}

void CConnman::DumpData()
{
DumpAddresses();
DumpBanlist();
}

void CConnman::ProcessOneShot()
{
std::string strDest;
Expand Down Expand Up @@ -2450,7 +2447,8 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
threadMessageHandler = std::thread(&TraceThread<std::function<void()> >, "msghand", std::function<void()>(std::bind(&CConnman::ThreadMessageHandler, this)));

// Dump network addresses
scheduler.scheduleEvery(std::bind(&CConnman::DumpData, this), DUMP_ADDRESSES_INTERVAL * 1000);
scheduler.scheduleEvery(std::bind(&CConnman::DumpAddresses, this), DUMP_PEERS_INTERVAL * 1000);
scheduler.scheduleEvery(std::bind(&CConnman::DumpBanlist, this), DUMP_BANS_INTERVAL * 1000);

return true;
}
Expand Down Expand Up @@ -2509,7 +2507,8 @@ void CConnman::Stop()

if (fAddressesInitialized)
{
DumpData();
DumpAddresses();
DumpBanlist();
fAddressesInitialized = false;
}

Expand Down

0 comments on commit 83c1ea2

Please sign in to comment.