Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/db.h
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | public: | ||||
void Update(bool good, int64_t age, double tau) { | void Update(bool good, int64_t age, double tau) { | ||||
double f = exp(-age / tau); | double f = exp(-age / tau); | ||||
reliability = reliability * f + (good ? (1.0 - f) : 0); | reliability = reliability * f + (good ? (1.0 - f) : 0); | ||||
count = count * f + 1; | count = count * f + 1; | ||||
weight = weight * f + (1.0 - f); | weight = weight * f + (1.0 - f); | ||||
} | } | ||||
ADD_SERIALIZE_METHODS; | SERIALIZE_METHODS(CAddrStat, obj) { | ||||
READWRITE(obj.weight, obj.count, obj.reliability); | |||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
READWRITE(weight); | |||||
READWRITE(count); | |||||
READWRITE(reliability); | |||||
} | } | ||||
friend class SeederAddrInfo; | friend class SeederAddrInfo; | ||||
}; | }; | ||||
class CAddrReport { | class CAddrReport { | ||||
public: | public: | ||||
CService ip; | CService ip; | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | int64_t GetIgnoreTime() const { | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
void Update(bool good); | void Update(bool good); | ||||
friend class CAddrDb; | friend class CAddrDb; | ||||
ADD_SERIALIZE_METHODS; | SERIALIZE_METHODS(SeederAddrInfo, obj) { | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
uint8_t version = 4; | uint8_t version = 4; | ||||
READWRITE(version); | READWRITE(version, obj.ip, obj.services, obj.lastTry); | ||||
READWRITE(ip); | uint8_t tried = obj.ourLastTry != 0; | ||||
READWRITE(services); | |||||
READWRITE(lastTry); | |||||
uint8_t tried = ourLastTry != 0; | |||||
READWRITE(tried); | READWRITE(tried); | ||||
if (!tried) { | if (!tried) { | ||||
return; | return; | ||||
} | } | ||||
READWRITE(ourLastTry); | READWRITE(obj.ourLastTry, obj.ignoreTill, obj.stat2H, obj.stat8H, | ||||
READWRITE(ignoreTill); | obj.stat1D, obj.stat1W); | ||||
READWRITE(stat2H); | |||||
READWRITE(stat8H); | |||||
READWRITE(stat1D); | |||||
READWRITE(stat1W); | |||||
if (version >= 1) { | if (version >= 1) { | ||||
READWRITE(stat1M); | READWRITE(obj.stat1M); | ||||
} else if (!ser_action.ForRead()) { | } else { | ||||
*((CAddrStat *)(&stat1M)) = stat1W; | SER_WRITE(obj, *((CAddrStat *)(&obj.stat1M)) = obj.stat1W); | ||||
} | } | ||||
READWRITE(total); | READWRITE(obj.total, obj.success, obj.clientVersion); | ||||
READWRITE(success); | |||||
READWRITE(clientVersion); | |||||
if (version >= 2) { | if (version >= 2) { | ||||
READWRITE(clientSubVersion); | READWRITE(obj.clientSubVersion); | ||||
} | } | ||||
if (version >= 3) { | if (version >= 3) { | ||||
READWRITE(blocks); | READWRITE(obj.blocks); | ||||
} | } | ||||
if (version >= 4) { | if (version >= 4) { | ||||
READWRITE(ourLastSuccess); | READWRITE(obj.ourLastSuccess); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
class CAddrDbStats { | class CAddrDbStats { | ||||
public: | public: | ||||
int nBanned; | int nBanned; | ||||
int nAvail; | int nAvail; | ||||
▲ Show 20 Lines • Show All 205 Lines • Show Last 20 Lines |