Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | void BanMan::DumpBanlist() { | ||||
// Clean unused entries (if bantime has expired) | // Clean unused entries (if bantime has expired) | ||||
SweepBanned(); | SweepBanned(); | ||||
if (!BannedSetIsDirty()) { | if (!BannedSetIsDirty()) { | ||||
return; | return; | ||||
} | } | ||||
int64_t nStart = GetTimeMillis(); | int64_t nStart = GetTimeMillis(); | ||||
CBanDB bandb(params); | |||||
banmap_t banmap; | banmap_t banmap; | ||||
GetBanned(banmap); | GetBanned(banmap); | ||||
if (bandb.Write(banmap)) { | if (m_ban_db.Write(banmap)) { | ||||
SetBannedSetDirty(false); | SetBannedSetDirty(false); | ||||
} | } | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
"Flushed %d banned node ips/subnets to banlist.dat %dms\n", | "Flushed %d banned node ips/subnets to banlist.dat %dms\n", | ||||
banmap.size(), GetTimeMillis() - nStart); | banmap.size(), GetTimeMillis() - nStart); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,017 Lines • ▼ Show 20 Lines | scheduler.scheduleEvery( | ||||
this->DumpAddresses(); | this->DumpAddresses(); | ||||
return true; | return true; | ||||
}, | }, | ||||
DUMP_PEERS_INTERVAL * 1000); | DUMP_PEERS_INTERVAL * 1000); | ||||
return true; | return true; | ||||
} | } | ||||
BanMan::BanMan(const CChainParams &_params, | BanMan::BanMan(fs::path ban_file, const CChainParams &chainParams, | ||||
CClientUIInterface *client_interface) | CClientUIInterface *client_interface) | ||||
: clientInterface(client_interface), params(_params) { | : clientInterface(client_interface), | ||||
m_ban_db(std::move(ban_file), chainParams) { | |||||
if (clientInterface) { | if (clientInterface) { | ||||
clientInterface->InitMessage(_("Loading banlist...")); | clientInterface->InitMessage(_("Loading banlist...")); | ||||
} | } | ||||
// Load addresses from banlist.dat | |||||
int64_t nStart = GetTimeMillis(); | int64_t nStart = GetTimeMillis(); | ||||
setBannedIsDirty = false; | setBannedIsDirty = false; | ||||
CBanDB bandb(params); | |||||
banmap_t banmap; | banmap_t banmap; | ||||
if (bandb.Read(banmap)) { | if (m_ban_db.Read(banmap)) { | ||||
// thread save setter | // thread save setter | ||||
SetBanned(banmap); | SetBanned(banmap); | ||||
// no need to write down, just read data | // no need to write down, just read data | ||||
SetBannedSetDirty(false); | SetBannedSetDirty(false); | ||||
// sweep out unused entries | // sweep out unused entries | ||||
SweepBanned(); | SweepBanned(); | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
▲ Show 20 Lines • Show All 537 Lines • Show Last 20 Lines |