From 2ba9805c865280a6d52a1c20d6ab83d6cdf1eeb1 Mon Sep 17 00:00:00 2001 From: Don Shin Date: Sat, 14 Apr 2018 08:42:26 -0500 Subject: [PATCH 1/2] Updated protocol version to 180004, and updated the checks to accept new IP address requests from nodes down to protocol version 180003 but only report 180004 nodes. --- README.md | 4 ++-- db.h | 4 ++-- serialize.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ad213d8..b8ad75b 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ of reliable nodes via a built-in DNS server. Features: * regularly revisits known nodes to check their availability * bans nodes after enough failures, or bad behaviour -* accepts nodes down to v0.3.19 to request new IP addresses from, - but only reports good post-v0.3.24 nodes. +* accepts nodes down to protocol version 180003 to request new IP addresses from, + but only reports good (180004) nodes. * keeps statistics over (exponential) windows of 2 hours, 8 hours, 1 day and 1 week, to base decisions on. * very low memory (a few tens of megabytes) and cpu requirements. diff --git a/db.h b/db.h index 493f9ab..0c4da8d 100644 --- a/db.h +++ b/db.h @@ -12,7 +12,7 @@ #define MIN_RETRY 1000 -#define REQUIRE_VERSION 70001 +#define REQUIRE_VERSION 180004 static inline int GetRequireHeight(const bool testnet = fTestNet) { @@ -119,7 +119,7 @@ public: } int GetBanTime() const { if (IsGood()) return 0; - if (clientVersion && clientVersion < 31900) { return 604800; } + if (clientVersion && clientVersion < 180003) { return 604800; } if (stat1M.reliability - stat1M.weight + 1.0 < 0.15 && stat1M.count > 32) { return 30*86400; } if (stat1W.reliability - stat1W.weight + 1.0 < 0.10 && stat1W.count > 16) { return 7*86400; } if (stat1D.reliability - stat1D.weight + 1.0 < 0.05 && stat1D.count > 8) { return 1*86400; } diff --git a/serialize.h b/serialize.h index cbf6c13..9e714e2 100644 --- a/serialize.h +++ b/serialize.h @@ -60,7 +60,7 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int PROTOCOL_VERSION = 180003; +static const int PROTOCOL_VERSION = 180004; // Used to bypass the rule against non-const reference to temporary // where it makes sense with wrappers such as CFlatData or CTxDB From c3ce398cd37ec2eed5efbf89b48d7fbd662723ef Mon Sep 17 00:00:00 2001 From: Don Shin Date: Tue, 17 Apr 2018 23:49:56 -0500 Subject: [PATCH 2/2] Created define MINIMUM_VERSION_TO_AVOID_BAN_TIME for a numeric constant. --- db.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db.h b/db.h index 0c4da8d..2e0e1b4 100644 --- a/db.h +++ b/db.h @@ -12,7 +12,8 @@ #define MIN_RETRY 1000 -#define REQUIRE_VERSION 180004 +#define REQUIRED_VERSION 180004 +#define MINIMUM_VERSION_TO_AVOID_BAN_TIME 180003 static inline int GetRequireHeight(const bool testnet = fTestNet) { @@ -104,7 +105,7 @@ public: if (ip.GetPort() != GetDefaultPort()) return false; if (!(services & NODE_NETWORK)) return false; if (!ip.IsRoutable()) return false; - if (clientVersion && clientVersion < REQUIRE_VERSION) return false; + if (clientVersion && clientVersion < REQUIRED_VERSION) return false; if (blocks && blocks < GetRequireHeight()) return false; if (total <= 3 && success * 2 >= total) return true; @@ -119,7 +120,7 @@ public: } int GetBanTime() const { if (IsGood()) return 0; - if (clientVersion && clientVersion < 180003) { return 604800; } + if (clientVersion && clientVersion < MINIMUM_VERSION_TO_AVOID_BAN_TIME) { return 604800; } if (stat1M.reliability - stat1M.weight + 1.0 < 0.15 && stat1M.count > 32) { return 30*86400; } if (stat1W.reliability - stat1W.weight + 1.0 < 0.10 && stat1W.count > 16) { return 7*86400; } if (stat1D.reliability - stat1D.weight + 1.0 < 0.05 && stat1D.count > 8) { return 1*86400; }