diff --git a/src/seeder/db.h b/src/seeder/db.h --- a/src/seeder/db.h +++ b/src/seeder/db.h @@ -80,6 +80,7 @@ private: CService ip; uint64_t services; + int64_t timeFirstFound; int64_t lastTry; int64_t ourLastTry; int64_t ourLastSuccess; @@ -95,10 +96,17 @@ int success; std::string clientSubVersion; +protected: + bool hasRunTestNodeBefore() const { return total > 0; } + int64_t timeSinceFoundOrLastSuccess(int64_t now = time(nullptr)) { + return now - success > 0 ? ourLastSuccess : timeFirstFound; + } + public: CAddrInfo() - : services(0), lastTry(0), ourLastTry(0), ourLastSuccess(0), - ignoreTill(0), clientVersion(0), blocks(0), total(0), success(0) {} + : services(0), timeFirstFound(time(nullptr)), lastTry(0), ourLastTry(0), + ourLastSuccess(0), ignoreTill(0), clientVersion(0), blocks(0), + total(0), success(0) {} CAddrReport GetReport() const { CAddrReport ret; @@ -221,6 +229,7 @@ return; } + READWRITE(timeFirstFound); READWRITE(ourLastTry); READWRITE(ignoreTill); READWRITE(stat2H); @@ -260,11 +269,14 @@ struct CServiceResult { CService service; bool fGood; + bool fReliable; int nBanTime; int nHeight; int nClientV; std::string strClientV; int64_t ourLastSuccess; + bool hasRunTestNodeBefore; + int64_t timeSinceFoundOrLastSuccess; }; /** diff --git a/src/seeder/db.cpp b/src/seeder/db.cpp --- a/src/seeder/db.cpp +++ b/src/seeder/db.cpp @@ -69,6 +69,10 @@ } else { ip.service = idToInfo[ret].ip; ip.ourLastSuccess = idToInfo[ret].ourLastSuccess; + ip.hasRunTestNodeBefore = idToInfo[ret].hasRunTestNodeBefore(); + ip.fReliable = idToInfo[ret].IsGood(); + ip.timeSinceFoundOrLastSuccess = + idToInfo[ret].timeSinceFoundOrLastSuccess(); break; } } while (1); diff --git a/src/seeder/main.cpp b/src/seeder/main.cpp --- a/src/seeder/main.cpp +++ b/src/seeder/main.cpp @@ -194,6 +194,10 @@ res.fGood = TestNode(res.service, res.nBanTime, res.nClientV, res.strClientV, res.nHeight, getaddr ? &addr : nullptr); + if (!res.fGood && !res.fReliable && res.hasRunTestNodeBefore && + res.timeSinceFoundOrLastSuccess > 2 * 86400) { + res.nBanTime = std::max(100000, res.nBanTime); + } } db.ResultMany(ips);