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
Summary: his is a partial backport of Core PR14605 : bitcoin/bitcoin@83c1ea2

Test Plan:
  make check

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D4101
  • Loading branch information
theuni authored and deadalnix committed Sep 18, 2019
1 parent 8d8b46c commit 555fded
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@

#include <cmath>

// 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.
Expand Down Expand Up @@ -1767,11 +1770,6 @@ void CConnman::DumpAddresses() {
addrman.size(), GetTimeMillis() - nStart);
}

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

void CConnman::ProcessOneShot() {
std::string strDest;
{
Expand Down Expand Up @@ -2547,10 +2545,17 @@ bool CConnman::Start(CScheduler &scheduler, const Options &connOptions) {
// Dump network addresses
scheduler.scheduleEvery(
[this]() {
this->DumpData();
this->DumpAddresses();
return true;
},
DUMP_PEERS_INTERVAL * 1000);

scheduler.scheduleEvery(
[this]() {
this->DumpBanlist();
return true;
},
DUMP_ADDRESSES_INTERVAL * 1000);
DUMP_BANS_INTERVAL * 1000);

return true;
}
Expand Down Expand Up @@ -2608,7 +2613,8 @@ void CConnman::Stop() {
}

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

Expand Down

0 comments on commit 555fded

Please sign in to comment.