|
|
@ -422,6 +422,26 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest) |
|
|
|
return NULL; |
|
|
|
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() |
|
|
|
void CNode::CloseSocketDisconnect() |
|
|
|
{ |
|
|
|
{ |
|
|
|
fDisconnect = true; |
|
|
|
fDisconnect = true; |
|
|
@ -2607,26 +2627,6 @@ bool CBanDB::Read(banmap_t& banSet) |
|
|
|
return true; |
|
|
|
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) { |
|
|
|
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); |
|
|
|
return nNow + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5); |
|
|
|
} |
|
|
|
} |
|
|
|