mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
banlist: update set dirty to be more fine grained
- move the SetBannedSetDirty(false) call from DumpData() into DumpBanlist() - ensure we only set false, if the write succeeded
This commit is contained in:
parent
5ab5dca6f1
commit
57c77fe4d3
1 changed files with 4 additions and 7 deletions
11
src/net.cpp
11
src/net.cpp
|
@ -1455,10 +1455,7 @@ void DumpData()
|
||||||
DumpAddresses();
|
DumpAddresses();
|
||||||
|
|
||||||
if (CNode::BannedSetIsDirty())
|
if (CNode::BannedSetIsDirty())
|
||||||
{
|
|
||||||
DumpBanlist();
|
DumpBanlist();
|
||||||
CNode::SetBannedSetDirty(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void static ProcessOneShot()
|
void static ProcessOneShot()
|
||||||
|
@ -2484,14 +2481,14 @@ bool CBanDB::Read(banmap_t& banSet)
|
||||||
void DumpBanlist()
|
void DumpBanlist()
|
||||||
{
|
{
|
||||||
int64_t nStart = GetTimeMillis();
|
int64_t nStart = GetTimeMillis();
|
||||||
|
CNode::SweepBanned(); // clean unused entries (if bantime has expired)
|
||||||
CNode::SweepBanned(); //clean unused entries (if bantime has expired)
|
|
||||||
|
|
||||||
CBanDB bandb;
|
CBanDB bandb;
|
||||||
banmap_t banmap;
|
banmap_t banmap;
|
||||||
CNode::GetBanned(banmap);
|
CNode::GetBanned(banmap);
|
||||||
bandb.Write(banmap);
|
if (bandb.Write(banmap))
|
||||||
|
CNode::SetBannedSetDirty(false);
|
||||||
|
|
||||||
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
|
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
|
||||||
banmap.size(), GetTimeMillis() - nStart);
|
banmap.size(), GetTimeMillis() - nStart);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue