Skip to content

Commit 83c1ea2

Browse files
theunidongcarl
authored andcommitted
net: split up addresses/ban dumps in preparation for moving them
1 parent 136bd79 commit 83c1ea2

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/net.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@
4141

4242
#include <math.h>
4343

44-
// Dump addresses to peers.dat and banlist.dat every 15 minutes (900s)
45-
#define DUMP_ADDRESSES_INTERVAL 900
44+
// Dump addresses to peers.dat every 15 minutes (900s)
45+
static constexpr int DUMP_PEERS_INTERVAL = 15 * 60;
46+
47+
// Dump addresses to banlist.dat every 15 minutes (900s)
48+
static constexpr int DUMP_BANS_INTERVAL = 60 * 15;
4649

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

1771-
void CConnman::DumpData()
1772-
{
1773-
DumpAddresses();
1774-
DumpBanlist();
1775-
}
1776-
17771774
void CConnman::ProcessOneShot()
17781775
{
17791776
std::string strDest;
@@ -2450,7 +2447,8 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
24502447
threadMessageHandler = std::thread(&TraceThread<std::function<void()> >, "msghand", std::function<void()>(std::bind(&CConnman::ThreadMessageHandler, this)));
24512448

24522449
// Dump network addresses
2453-
scheduler.scheduleEvery(std::bind(&CConnman::DumpData, this), DUMP_ADDRESSES_INTERVAL * 1000);
2450+
scheduler.scheduleEvery(std::bind(&CConnman::DumpAddresses, this), DUMP_PEERS_INTERVAL * 1000);
2451+
scheduler.scheduleEvery(std::bind(&CConnman::DumpBanlist, this), DUMP_BANS_INTERVAL * 1000);
24542452

24552453
return true;
24562454
}
@@ -2509,7 +2507,8 @@ void CConnman::Stop()
25092507

25102508
if (fAddressesInitialized)
25112509
{
2512-
DumpData();
2510+
DumpAddresses();
2511+
DumpBanlist();
25132512
fAddressesInitialized = false;
25142513
}
25152514

0 commit comments

Comments
 (0)