banlist: add more banlist infos to log / add GUI signal

- to match the peers.dat handling also supply a debug.log entry for how
  many entries were loaded from banlist.dat and how long it took
- add a GUI init message for loading the banlist (same as with peers.dat)

- move the same message for peers.dat upwards in the code, to be able to
  reuse the timing variable nStart and also just log, if our read from
  peers.dat didn't fail
This commit is contained in:
Philip Kaufmann 2015-07-03 09:46:17 +02:00
parent ce479aaada
commit 2977c243ef

View File

@ -35,7 +35,7 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
// Dump addresses to peers.dat every 15 minutes (900s) // Dump addresses to peers.dat and banlist.dat every 15 minutes (900s)
#define DUMP_ADDRESSES_INTERVAL 900 #define DUMP_ADDRESSES_INTERVAL 900
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL) #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
@ -555,11 +555,13 @@ void CNode::SweepBanned()
banmap_t::iterator it = setBanned.begin(); banmap_t::iterator it = setBanned.begin();
while(it != setBanned.end()) while(it != setBanned.end())
{ {
CSubNet subNet = (*it).first;
CBanEntry banEntry = (*it).second; CBanEntry banEntry = (*it).second;
if(now > banEntry.nBanUntil) if(now > banEntry.nBanUntil)
{ {
setBanned.erase(it++); setBanned.erase(it++);
setBannedIsDirty = true; setBannedIsDirty = true;
LogPrint("net", "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString());
} }
else else
++it; ++it;
@ -1898,15 +1900,19 @@ void static Discover(boost::thread_group& threadGroup)
void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
{ {
uiInterface.InitMessage(_("Loading addresses...")); uiInterface.InitMessage(_("Loading addresses..."));
// Load addresses for peers.dat // Load addresses from peers.dat
int64_t nStart = GetTimeMillis(); int64_t nStart = GetTimeMillis();
{ {
CAddrDB adb; CAddrDB adb;
if (!adb.Read(addrman)) if (adb.Read(addrman))
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart);
else
LogPrintf("Invalid or missing peers.dat; recreating\n"); LogPrintf("Invalid or missing peers.dat; recreating\n");
} }
//try to read stored banlist uiInterface.InitMessage(_("Loading banlist..."));
// Load addresses from banlist.dat
nStart = GetTimeMillis();
CBanDB bandb; CBanDB bandb;
banmap_t banmap; banmap_t banmap;
if (bandb.Read(banmap)) { if (bandb.Read(banmap)) {
@ -1923,7 +1929,7 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
if (semOutbound == NULL) { if (semOutbound == NULL) {
// initialize semaphore // initialize semaphore
int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections); int nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
semOutbound = new CSemaphore(nMaxOutbound); semOutbound = new CSemaphore(nMaxOutbound);
} }