Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/db.h
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | CAddrReport GetReport() const { | ||||
ret.clientSubVersion = clientSubVersion; | ret.clientSubVersion = clientSubVersion; | ||||
ret.blocks = blocks; | ret.blocks = blocks; | ||||
ret.uptime[0] = stat2H.reliability; | ret.uptime[0] = stat2H.reliability; | ||||
ret.uptime[1] = stat8H.reliability; | ret.uptime[1] = stat8H.reliability; | ||||
ret.uptime[2] = stat1D.reliability; | ret.uptime[2] = stat1D.reliability; | ||||
ret.uptime[3] = stat1W.reliability; | ret.uptime[3] = stat1W.reliability; | ||||
ret.uptime[4] = stat1M.reliability; | ret.uptime[4] = stat1M.reliability; | ||||
ret.lastSuccess = ourLastSuccess; | ret.lastSuccess = ourLastSuccess; | ||||
ret.fGood = IsGood(); | ret.fGood = IsReliable(); | ||||
ret.services = services; | ret.services = services; | ||||
return ret; | return ret; | ||||
} | } | ||||
bool IsGood() const { | bool IsReliable() const { | ||||
if (ip.GetPort() != GetDefaultPort()) { | if (ip.GetPort() != GetDefaultPort()) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!(services & NODE_NETWORK)) { | if (!(services & NODE_NETWORK)) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!ip.IsRoutable()) { | if (!ip.IsRoutable()) { | ||||
return false; | return false; | ||||
Show All 24 Lines | bool IsReliable() const { | ||||
if (stat1M.reliability > 0.35 && stat1M.count > 32) { | if (stat1M.reliability > 0.35 && stat1M.count > 32) { | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
int64_t GetBanTime() const { | int64_t GetBanTime() const { | ||||
if (IsGood()) { | if (IsReliable()) { | ||||
return 0; | return 0; | ||||
} | } | ||||
if (clientVersion && clientVersion < 31900) { | if (clientVersion && clientVersion < 31900) { | ||||
return 604800; | return 604800; | ||||
} | } | ||||
if (stat1M.reliability - stat1M.weight + 1.0 < 0.15 && | if (stat1M.reliability - stat1M.weight + 1.0 < 0.15 && | ||||
stat1M.count > 32) { | stat1M.count > 32) { | ||||
return 30 * 86400; | return 30 * 86400; | ||||
} | } | ||||
if (stat1W.reliability - stat1W.weight + 1.0 < 0.10 && | if (stat1W.reliability - stat1W.weight + 1.0 < 0.10 && | ||||
stat1W.count > 16) { | stat1W.count > 16) { | ||||
return 7 * 86400; | return 7 * 86400; | ||||
} | } | ||||
if (stat1D.reliability - stat1D.weight + 1.0 < 0.05 && | if (stat1D.reliability - stat1D.weight + 1.0 < 0.05 && | ||||
stat1D.count > 8) { | stat1D.count > 8) { | ||||
return 1 * 86400; | return 1 * 86400; | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
int64_t GetIgnoreTime() const { | int64_t GetIgnoreTime() const { | ||||
if (IsGood()) { | if (IsReliable()) { | ||||
return 0; | return 0; | ||||
} | } | ||||
if (stat1M.reliability - stat1M.weight + 1.0 < 0.20 && | if (stat1M.reliability - stat1M.weight + 1.0 < 0.20 && | ||||
stat1M.count > 2) { | stat1M.count > 2) { | ||||
return 10 * 86400; | return 10 * 86400; | ||||
} | } | ||||
if (stat1W.reliability - stat1W.weight + 1.0 < 0.16 && | if (stat1W.reliability - stat1W.weight + 1.0 < 0.16 && | ||||
stat1W.count > 2) { | stat1W.count > 2) { | ||||
▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | template <typename Stream> void Unserialize(Stream &s) { | ||||
CAddrInfo info; | CAddrInfo info; | ||||
s >> info; | s >> info; | ||||
if (!info.GetBanTime()) { | if (!info.GetBanTime()) { | ||||
int id = db->nId++; | int id = db->nId++; | ||||
db->idToInfo[id] = info; | db->idToInfo[id] = info; | ||||
db->ipToId[info.ip] = id; | db->ipToId[info.ip] = id; | ||||
if (info.ourLastTry) { | if (info.ourLastTry) { | ||||
db->ourId.push_back(id); | db->ourId.push_back(id); | ||||
if (info.IsGood()) { | if (info.IsReliable()) { | ||||
db->goodId.insert(id); | db->goodId.insert(id); | ||||
} | } | ||||
} else { | } else { | ||||
db->unkId.insert(id); | db->unkId.insert(id); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
db->nDirty++; | db->nDirty++; | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |