Browse Source

net: No need to export DumpBanlist

0.13
Cory Fields 9 years ago
parent
commit
e9ed6206b3
  1. 40
      src/net.cpp
  2. 2
      src/net.h

40
src/net.cpp

@ -422,6 +422,26 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest) @@ -422,6 +422,26 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
return NULL;
}
static void DumpBanlist()
{
CNode::SweepBanned(); // clean unused entries (if bantime has expired)
if (!CNode::BannedSetIsDirty())
return;
int64_t nStart = GetTimeMillis();
CBanDB bandb;
banmap_t banmap;
CNode::SetBannedSetDirty(false);
CNode::GetBanned(banmap);
if (!bandb.Write(banmap))
CNode::SetBannedSetDirty(true);
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
banmap.size(), GetTimeMillis() - nStart);
}
void CNode::CloseSocketDisconnect()
{
fDisconnect = true;
@ -2607,26 +2627,6 @@ bool CBanDB::Read(banmap_t& banSet) @@ -2607,26 +2627,6 @@ bool CBanDB::Read(banmap_t& banSet)
return true;
}
void DumpBanlist()
{
CNode::SweepBanned(); // clean unused entries (if bantime has expired)
if (!CNode::BannedSetIsDirty())
return;
int64_t nStart = GetTimeMillis();
CBanDB bandb;
banmap_t banmap;
CNode::SetBannedSetDirty(false);
CNode::GetBanned(banmap);
if (!bandb.Write(banmap))
CNode::SetBannedSetDirty(true);
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
banmap.size(), GetTimeMillis() - nStart);
}
int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) {
return nNow + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5);
}

2
src/net.h

@ -807,8 +807,6 @@ public: @@ -807,8 +807,6 @@ public:
bool Read(banmap_t& banSet);
};
void DumpBanlist();
/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */
int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds);

Loading…
Cancel
Save