banlist: better handling of banlist in StartNode()

- only start working on/with banlist data, if reading in the banlist from
  disk didn't fail
- as CNode::setBannedIsDirty is false (default) when reading fails, we
  don't need to explicitly set it to false to prevent writing
  banlist.dat in that case either
This commit is contained in:
Philip Kaufmann 2015-07-03 09:44:49 +02:00
parent 57c77fe4d3
commit ce479aaada

View file

@ -1909,15 +1909,16 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
//try to read stored banlist //try to read stored banlist
CBanDB bandb; CBanDB bandb;
banmap_t banmap; banmap_t banmap;
if (!bandb.Read(banmap)) if (bandb.Read(banmap)) {
CNode::SetBanned(banmap); // thread save setter
CNode::SetBannedSetDirty(false); // no need to write down, just read data
CNode::SweepBanned(); // sweep out unused entries
LogPrint("net", "Loaded %d banned node ips/subnets from banlist.dat %dms\n",
banmap.size(), GetTimeMillis() - nStart);
} else
LogPrintf("Invalid or missing banlist.dat; recreating\n"); LogPrintf("Invalid or missing banlist.dat; recreating\n");
CNode::SetBanned(banmap); //thread save setter
CNode::SetBannedSetDirty(false); //no need to write down just read or nonexistent data
CNode::SweepBanned(); //sweap out unused entries
LogPrintf("Loaded %i addresses from peers.dat %dms\n",
addrman.size(), GetTimeMillis() - nStart);
fAddressesInitialized = true; fAddressesInitialized = true;
if (semOutbound == NULL) { if (semOutbound == NULL) {