Browse Source

Merge pull request #9 from luke-jr/more_detail

More detail
pull/1/head
Pieter Wuille 11 years ago
parent
commit
915ce6317f
  1. 6
      db.cpp
  2. 13
      db.h
  3. 6
      main.cpp

6
db.cpp

@ -11,7 +11,11 @@ void CAddrInfo::Update(bool good) { @@ -11,7 +11,11 @@ void CAddrInfo::Update(bool good) {
lastTry = now;
ourLastTry = now;
total++;
if (good) success++;
if (good)
{
success++;
ourLastSuccess = now;
}
stat2H.Update(good, age, 3600*2);
stat8H.Update(good, age, 3600*8);
stat1D.Update(good, age, 3600*24);

13
db.h

@ -52,6 +52,9 @@ public: @@ -52,6 +52,9 @@ public:
int blocks;
double uptime[5];
std::string clientSubVersion;
int64_t lastSuccess;
bool fGood;
uint64_t services;
};
@ -61,6 +64,7 @@ private: @@ -61,6 +64,7 @@ private:
uint64_t services;
int64 lastTry;
int64 ourLastTry;
int64 ourLastSuccess;
int64 ignoreTill;
CAddrStat stat2H;
CAddrStat stat8H;
@ -73,7 +77,7 @@ private: @@ -73,7 +77,7 @@ private:
int success;
std::string clientSubVersion;
public:
CAddrInfo() : services(0), lastTry(0), ourLastTry(0), ignoreTill(0), clientVersion(0), blocks(0), total(0), success(0) {}
CAddrInfo() : services(0), lastTry(0), ourLastTry(0), ourLastSuccess(0), ignoreTill(0), clientVersion(0), blocks(0), total(0), success(0) {}
CAddrReport GetReport() const {
CAddrReport ret;
@ -86,6 +90,9 @@ public: @@ -86,6 +90,9 @@ public:
ret.uptime[2] = stat1D.reliability;
ret.uptime[3] = stat1W.reliability;
ret.uptime[4] = stat1M.reliability;
ret.lastSuccess = ourLastSuccess;
ret.fGood = IsGood();
ret.services = services;
return ret;
}
@ -126,7 +133,7 @@ public: @@ -126,7 +133,7 @@ public:
friend class CAddrDb;
IMPLEMENT_SERIALIZE (
unsigned char version = 3;
unsigned char version = 4;
READWRITE(version);
READWRITE(ip);
READWRITE(services);
@ -152,6 +159,8 @@ public: @@ -152,6 +159,8 @@ public:
READWRITE(clientSubVersion);
if (version >= 3)
READWRITE(blocks);
if (version >= 4)
READWRITE(ourLastSuccess);
}
)
};

6
main.cpp

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
#include <algorithm>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
@ -284,11 +286,11 @@ extern "C" void* ThreadDumper(void*) { @@ -284,11 +286,11 @@ extern "C" void* ThreadDumper(void*) {
rename("dnsseed.dat.new", "dnsseed.dat");
}
FILE *d = fopen("dnsseed.dump", "w");
fprintf(d, "# address \t%%(2h)\t%%(8h)\t%%(1d)\t%%(7d)\t%%(30d)\tblocks\tversion\n");
fprintf(d, "# address \tgood\tlastSuccess\t%%(2h)\t%%(8h)\t%%(1d)\t%%(7d)\t%%(30d)\tblocks\tsvcs\tversion\n");
double stat[5]={0,0,0,0,0};
for (vector<CAddrReport>::const_iterator it = v.begin(); it < v.end(); it++) {
CAddrReport rep = *it;
fprintf(d, "%s\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%i\t%i \"%s\"\n", rep.ip.ToString().c_str(), 100.0*rep.uptime[0], 100.0*rep.uptime[1], 100.0*rep.uptime[2], 100.0*rep.uptime[3], 100.0*rep.uptime[4], rep.blocks, rep.clientVersion, rep.clientSubVersion.c_str());
fprintf(d, "%s\t%d\t%"PRId64"\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%i\t%"PRIx64"\t%i \"%s\"\n", rep.ip.ToString().c_str(), (int)rep.fGood, rep.lastSuccess, 100.0*rep.uptime[0], 100.0*rep.uptime[1], 100.0*rep.uptime[2], 100.0*rep.uptime[3], 100.0*rep.uptime[4], rep.blocks, rep.services, rep.clientVersion, rep.clientSubVersion.c_str());
stat[0] += rep.uptime[0];
stat[1] += rep.uptime[1];
stat[2] += rep.uptime[2];

Loading…
Cancel
Save