begin multitau
This commit is contained in:
parent
d14cd8adb6
commit
8286cf33f1
2 changed files with 12 additions and 5 deletions
5
db.cpp
5
db.cpp
|
@ -7,11 +7,6 @@ void CAddrInfo::Update(bool good) {
|
||||||
uint32_t now = time(NULL);
|
uint32_t now = time(NULL);
|
||||||
if (ourLastTry == 0)
|
if (ourLastTry == 0)
|
||||||
ourLastTry = now - MIN_RETRY;
|
ourLastTry = now - MIN_RETRY;
|
||||||
double f = exp(-(now-ourLastTry)/TAU);
|
|
||||||
reliability = reliability * f + (good ? (1.0-f) : 0);
|
|
||||||
timing = (timing + (now-ourLastTry) * weight) * f;
|
|
||||||
count = count * f + 1;
|
|
||||||
weight = weight * f + (1.0-f);
|
|
||||||
lastTry = now;
|
lastTry = now;
|
||||||
ourLastTry = now;
|
ourLastTry = now;
|
||||||
total++;
|
total++;
|
||||||
|
|
12
db.h
12
db.h
|
@ -19,6 +19,18 @@ std::string static inline ToString(const CIPPort &ip) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<float tau> class CAddrStat {
|
||||||
|
private:
|
||||||
|
float reliability;
|
||||||
|
float timing;
|
||||||
|
float count;
|
||||||
|
float weight;
|
||||||
|
public:
|
||||||
|
void Update(bool good, int64 tim) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class CAddrInfo {
|
class CAddrInfo {
|
||||||
private:
|
private:
|
||||||
CIPPort ip;
|
CIPPort ip;
|
||||||
|
|
Loading…
Add table
Reference in a new issue