diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/banman.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/banman.cpp b/src/banman.cpp index 95b927c1ff..b28e3f7f7c 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -7,6 +7,7 @@ #include <netaddress.h> #include <node/ui_interface.h> +#include <sync.h> #include <util/system.h> #include <util/time.h> #include <util/translation.h> @@ -39,18 +40,23 @@ BanMan::~BanMan() void BanMan::DumpBanlist() { - SweepBanned(); // clean unused entries (if bantime has expired) - - if (!BannedSetIsDirty()) return; - - int64_t n_start = GetTimeMillis(); + static Mutex dump_mutex; + LOCK(dump_mutex); banmap_t banmap; - GetBanned(banmap); - if (m_ban_db.Write(banmap)) { + { + LOCK(m_cs_banned); + SweepBanned(); + if (!BannedSetIsDirty()) return; + banmap = m_banned; SetBannedSetDirty(false); } + int64_t n_start = GetTimeMillis(); + if (!m_ban_db.Write(banmap)) { + SetBannedSetDirty(true); + } + LogPrint(BCLog::NET, "Flushed %d banned node addresses/subnets to disk %dms\n", banmap.size(), GetTimeMillis() - n_start); } |