From c4930f33125eef6dc035e51c95691054289cc461 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 15 Apr 2013 03:15:53 +0000 Subject: [PATCH 1/4] Remember the last successful poll time for each node --- db.cpp | 6 +++++- db.h | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/db.cpp b/db.cpp index 4849014..592d68a 100644 --- a/db.cpp +++ b/db.cpp @@ -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); diff --git a/db.h b/db.h index 1946492..b55dce1 100644 --- a/db.h +++ b/db.h @@ -61,6 +61,7 @@ private: uint64_t services; int64 lastTry; int64 ourLastTry; + int64 ourLastSuccess; int64 ignoreTill; CAddrStat stat2H; CAddrStat stat8H; @@ -73,7 +74,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; @@ -126,7 +127,7 @@ public: friend class CAddrDb; IMPLEMENT_SERIALIZE ( - unsigned char version = 3; + unsigned char version = 4; READWRITE(version); READWRITE(ip); READWRITE(services); @@ -152,6 +153,8 @@ public: READWRITE(clientSubVersion); if (version >= 3) READWRITE(blocks); + if (version >= 4) + READWRITE(ourLastSuccess); } ) }; From 9856ac750e7ebdddb7e89d730257877797dd3fe3 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 15 Apr 2013 03:16:20 +0000 Subject: [PATCH 2/4] DUMP FORMAT CHANGE: Include last successful poll time in dnsseed.dump --- db.h | 2 ++ main.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/db.h b/db.h index b55dce1..3a505c2 100644 --- a/db.h +++ b/db.h @@ -52,6 +52,7 @@ public: int blocks; double uptime[5]; std::string clientSubVersion; + int64_t lastSuccess; }; @@ -87,6 +88,7 @@ public: ret.uptime[2] = stat1D.reliability; ret.uptime[3] = stat1W.reliability; ret.uptime[4] = stat1M.reliability; + ret.lastSuccess = ourLastSuccess; return ret; } diff --git a/main.cpp b/main.cpp index 442ab2e..88829ee 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,7 @@ #include +#define __STDC_FORMAT_MACROS +#include #include #include #include @@ -281,11 +283,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 \tlastSuccess\t%%(2h)\t%%(8h)\t%%(1d)\t%%(7d)\t%%(30d)\tblocks\tversion\n"); double stat[5]={0,0,0,0,0}; for (vector::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%"PRId64"\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%i\t%i \"%s\"\n", rep.ip.ToString().c_str(), 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.clientVersion, rep.clientSubVersion.c_str()); stat[0] += rep.uptime[0]; stat[1] += rep.uptime[1]; stat[2] += rep.uptime[2]; From bfc7d2f9efdf255545bb70fe4156c71bcb38415e Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 15 Apr 2013 03:21:27 +0000 Subject: [PATCH 3/4] DUMP FORMAT CHANGE: Include "good" flag in dnsseed.dump --- db.h | 2 ++ main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/db.h b/db.h index 3a505c2..941d84b 100644 --- a/db.h +++ b/db.h @@ -53,6 +53,7 @@ public: double uptime[5]; std::string clientSubVersion; int64_t lastSuccess; + bool fGood; }; @@ -89,6 +90,7 @@ public: ret.uptime[3] = stat1W.reliability; ret.uptime[4] = stat1M.reliability; ret.lastSuccess = ourLastSuccess; + ret.fGood = IsGood(); return ret; } diff --git a/main.cpp b/main.cpp index 88829ee..b3a6376 100644 --- a/main.cpp +++ b/main.cpp @@ -283,11 +283,11 @@ extern "C" void* ThreadDumper(void*) { rename("dnsseed.dat.new", "dnsseed.dat"); } FILE *d = fopen("dnsseed.dump", "w"); - fprintf(d, "# address \tlastSuccess\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\tversion\n"); double stat[5]={0,0,0,0,0}; for (vector::const_iterator it = v.begin(); it < v.end(); it++) { CAddrReport rep = *it; - fprintf(d, "%s\t%"PRId64"\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%i\t%i \"%s\"\n", rep.ip.ToString().c_str(), 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.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%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.clientVersion, rep.clientSubVersion.c_str()); stat[0] += rep.uptime[0]; stat[1] += rep.uptime[1]; stat[2] += rep.uptime[2]; From e3a5f2f325fbb4a406f9740bb2b6beaafa8e464a Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 15 Apr 2013 03:32:56 +0000 Subject: [PATCH 4/4] DUMP FORMAT CHANGE: Include service flags in dnsseed.dump as hex --- db.h | 2 ++ main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/db.h b/db.h index 941d84b..1e17733 100644 --- a/db.h +++ b/db.h @@ -54,6 +54,7 @@ public: std::string clientSubVersion; int64_t lastSuccess; bool fGood; + uint64_t services; }; @@ -91,6 +92,7 @@ public: ret.uptime[4] = stat1M.reliability; ret.lastSuccess = ourLastSuccess; ret.fGood = IsGood(); + ret.services = services; return ret; } diff --git a/main.cpp b/main.cpp index b3a6376..f1d4c45 100644 --- a/main.cpp +++ b/main.cpp @@ -283,11 +283,11 @@ extern "C" void* ThreadDumper(void*) { rename("dnsseed.dat.new", "dnsseed.dat"); } FILE *d = fopen("dnsseed.dump", "w"); - fprintf(d, "# address \tgood\tlastSuccess\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::const_iterator it = v.begin(); it < v.end(); it++) { CAddrReport rep = *it; - fprintf(d, "%s\t%d\t%"PRId64"\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%.2f%%\t%i\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.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];