Browse Source

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
0.13
Philip Kaufmann 10 years ago
parent
commit
ce479aaada
  1. 15
      src/net.cpp

15
src/net.cpp

@ -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)) {
LogPrintf("Invalid or missing banlist.dat; recreating\n");
CNode::SetBanned(banmap); // thread save setter CNode::SetBanned(banmap); // thread save setter
CNode::SetBannedSetDirty(false); //no need to write down just read or nonexistent data CNode::SetBannedSetDirty(false); // no need to write down, just read data
CNode::SweepBanned(); //sweap out unused entries 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("Loaded %i addresses from peers.dat %dms\n",
addrman.size(), GetTimeMillis() - nStart);
fAddressesInitialized = true; fAddressesInitialized = true;
if (semOutbound == NULL) { if (semOutbound == NULL) {

Loading…
Cancel
Save