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,20 @@ int success; std::string clientSubVersion; +protected: + bool hasBeenTriedBefore() const { return total > 0; } + int64_t timeSinceFoundOrLastSuccess() { + int64_t now = time(nullptr); + int64_t lastSuccessOrFirstFoundTime = + success > 0 ? ourLastSuccess : timeFirstFound; + return now - lastSuccessOrFirstFoundTime; + } + 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 +232,7 @@ return; } + READWRITE(timeFirstFound); READWRITE(ourLastTry); READWRITE(ignoreTill); READWRITE(stat2H); @@ -260,6 +272,7 @@ struct CServiceResult { CService service; bool fGood; + bool fReliable; int nBanTime; int nHeight; int nClientV; 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,9 @@ } else { ip.service = idToInfo[ret].ip; ip.ourLastSuccess = idToInfo[ret].ourLastSuccess; + ip.fReliable = + idToInfo[ret].IsGood() && idToInfo[ret].hasBeenTriedBefore() && + idToInfo[ret].timeSinceFoundOrLastSuccess() > 2 * 86400; 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 @@ -204,6 +204,9 @@ // tfm::format(std::cout, "%s: %s!!!\n", cip.ToString().c_str(), // ret ? "GOOD" : "BAD"); res.fGood = ret; + if (!res.fGood && !res.fReliable) { + res.nBanTime = 100000; + } } catch (std::ios_base::failure &e) { res.nBanTime = 0; res.fGood = false;