Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 614 Lines • ▼ Show 20 Lines | |||||
void CConnman::SetBanned(const banmap_t &banMap) { | void CConnman::SetBanned(const banmap_t &banMap) { | ||||
LOCK(cs_setBanned); | LOCK(cs_setBanned); | ||||
setBanned = banMap; | setBanned = banMap; | ||||
setBannedIsDirty = true; | setBannedIsDirty = true; | ||||
} | } | ||||
void CConnman::SweepBanned() { | void CConnman::SweepBanned() { | ||||
int64_t now = GetTime(); | int64_t now = GetTime(); | ||||
bool notifyUI = false; | |||||
{ | |||||
LOCK(cs_setBanned); | LOCK(cs_setBanned); | ||||
banmap_t::iterator it = setBanned.begin(); | banmap_t::iterator it = setBanned.begin(); | ||||
while (it != setBanned.end()) { | while (it != setBanned.end()) { | ||||
CSubNet subNet = (*it).first; | CSubNet subNet = (*it).first; | ||||
CBanEntry banEntry = (*it).second; | CBanEntry banEntry = (*it).second; | ||||
if (now > banEntry.nBanUntil) { | if (now > banEntry.nBanUntil) { | ||||
setBanned.erase(it++); | setBanned.erase(it++); | ||||
setBannedIsDirty = true; | setBannedIsDirty = true; | ||||
LogPrint(BCLog::NET, | notifyUI = true; | ||||
LogPrint( | |||||
BCLog::NET, | |||||
"%s: Removed banned node ip/subnet from banlist.dat: %s\n", | "%s: Removed banned node ip/subnet from banlist.dat: %s\n", | ||||
__func__, subNet.ToString()); | __func__, subNet.ToString()); | ||||
} else { | } else { | ||||
++it; | ++it; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// update UI | |||||
if (notifyUI && clientInterface) { | |||||
clientInterface->BannedListChanged(); | |||||
} | |||||
} | |||||
bool CConnman::BannedSetIsDirty() { | bool CConnman::BannedSetIsDirty() { | ||||
LOCK(cs_setBanned); | LOCK(cs_setBanned); | ||||
return setBannedIsDirty; | return setBannedIsDirty; | ||||
} | } | ||||
void CConnman::SetBannedSetDirty(bool dirty) { | void CConnman::SetBannedSetDirty(bool dirty) { | ||||
// Reuse setBanned lock for the isDirty flag. | // Reuse setBanned lock for the isDirty flag. | ||||
LOCK(cs_setBanned); | LOCK(cs_setBanned); | ||||
▲ Show 20 Lines • Show All 2,439 Lines • Show Last 20 Lines |