Updated for 1.0.15

This commit is contained in:
J62 2019-10-17 05:42:39 -07:00
parent 783f5dd534
commit 08758cf8f7
4 changed files with 20 additions and 20 deletions

View File

@ -7,8 +7,8 @@ of reliable nodes via a built-in DNS server.
Features: Features:
* regularly revisits known nodes to check their availability * regularly revisits known nodes to check their availability
* bans nodes after enough failures, or bad behaviour * bans nodes after enough failures, or bad behaviour
* accepts nodes down to protocol version 180004 to request new IP addresses from, * accepts nodes down to protocol version 180005 to request new IP addresses from,
but only reports good (180005) nodes. but only reports good (180006) nodes.
* keeps statistics over (exponential) windows of 2 hours, 8 hours, * keeps statistics over (exponential) windows of 2 hours, 8 hours,
1 day and 1 week, to base decisions on. 1 day and 1 week, to base decisions on.
* very low memory (a few tens of megabytes) and cpu requirements. * very low memory (a few tens of megabytes) and cpu requirements.

26
db.h
View File

@ -12,8 +12,8 @@
#define MIN_RETRY 1000 #define MIN_RETRY 1000
#define REQUIRED_VERSION 180005 #define REQUIRED_VERSION 180006
#define MINIMUM_VERSION_TO_AVOID_BAN_TIME 180004 #define MINIMUM_VERSION_TO_AVOID_BAN_TIME 180005
static inline int GetRequireHeight(const bool testnet = fTestNet) static inline int GetRequireHeight(const bool testnet = fTestNet)
{ {
@ -40,7 +40,7 @@ public:
count = count * f + 1; count = count * f + 1;
weight = weight * f + (1.0-f); weight = weight * f + (1.0-f);
} }
IMPLEMENT_SERIALIZE ( IMPLEMENT_SERIALIZE (
READWRITE(weight); READWRITE(weight);
READWRITE(count); READWRITE(count);
@ -83,7 +83,7 @@ private:
std::string clientSubVersion; std::string clientSubVersion;
public: public:
CAddrInfo() : services(0), lastTry(0), ourLastTry(0), ourLastSuccess(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 GetReport() const {
CAddrReport ret; CAddrReport ret;
ret.ip = ip; ret.ip = ip;
@ -100,7 +100,7 @@ public:
ret.services = services; ret.services = services;
return ret; return ret;
} }
bool IsGood() const { bool IsGood() const {
if (ip.GetPort() != GetDefaultPort()) return false; if (ip.GetPort() != GetDefaultPort()) return false;
if (!(services & NODE_NETWORK)) return false; if (!(services & NODE_NETWORK)) return false;
@ -115,7 +115,7 @@ public:
if (stat1D.reliability > 0.55 && stat1D.count > 8) return true; if (stat1D.reliability > 0.55 && stat1D.count > 8) return true;
if (stat1W.reliability > 0.45 && stat1W.count > 16) return true; if (stat1W.reliability > 0.45 && stat1W.count > 16) return true;
if (stat1M.reliability > 0.35 && stat1M.count > 32) return true; if (stat1M.reliability > 0.35 && stat1M.count > 32) return true;
return false; return false;
} }
int GetBanTime() const { int GetBanTime() const {
@ -134,11 +134,11 @@ public:
if (stat8H.reliability - stat8H.weight + 1.0 < 0.08 && stat8H.count > 2) { return 2*3600; } if (stat8H.reliability - stat8H.weight + 1.0 < 0.08 && stat8H.count > 2) { return 2*3600; }
return 0; return 0;
} }
void Update(bool good); void Update(bool good);
friend class CAddrDb; friend class CAddrDb;
IMPLEMENT_SERIALIZE ( IMPLEMENT_SERIALIZE (
unsigned char version = 4; unsigned char version = 4;
READWRITE(version); READWRITE(version);
@ -198,7 +198,7 @@ struct CServiceResult {
// / | \ // / | \
// tracked nodes (b) unknown nodes (e) active nodes // tracked nodes (b) unknown nodes (e) active nodes
// / \ // / \
// (d) good nodes (c) non-good nodes // (d) good nodes (c) non-good nodes
class CAddrDb { class CAddrDb {
private: private:
@ -210,7 +210,7 @@ private:
std::set<int> unkId; // set of nodes not yet tried (b) std::set<int> unkId; // set of nodes not yet tried (b)
std::set<int> goodId; // set of good nodes (d, good e) std::set<int> goodId; // set of good nodes (d, good e)
int nDirty; int nDirty;
protected: protected:
// internal routines that assume proper locks are acquired // internal routines that assume proper locks are acquired
void Add_(const CAddress &addr, bool force); // add an address void Add_(const CAddress &addr, bool force); // add an address
@ -241,7 +241,7 @@ public:
(*it).second.ignoreTill = 0; (*it).second.ignoreTill = 0;
} }
} }
std::vector<CAddrReport> GetAll() { std::vector<CAddrReport> GetAll() {
std::vector<CAddrReport> ret; std::vector<CAddrReport> ret;
SHARED_CRITICAL_BLOCK(cs) { SHARED_CRITICAL_BLOCK(cs) {
@ -254,7 +254,7 @@ public:
} }
return ret; return ret;
} }
// serialization code // serialization code
// format: // format:
// nVersion (0 for now) // nVersion (0 for now)

View File

@ -82,17 +82,17 @@ public:
host = optarg; host = optarg;
break; break;
} }
case 'm': { case 'm': {
mbox = optarg; mbox = optarg;
break; break;
} }
case 'n': { case 'n': {
ns = optarg; ns = optarg;
break; break;
} }
case 't': { case 't': {
int n = strtol(optarg, NULL, 10); int n = strtol(optarg, NULL, 10);
if (n > 0 && n < 1000) nThreads = n; if (n > 0 && n < 1000) nThreads = n;
@ -390,7 +390,7 @@ extern "C" void* ThreadStats(void*) {
return nullptr; return nullptr;
} }
static const string mainnet_seeds[] = {"dnsseed.btcprivate.org","explorer.btcprivate.org",""}; static const string mainnet_seeds[] = {"dnsseed.btcprivate.org","explorer.btcprivate.org","dnsseed.interbiznw.com",""};
static const string testnet_seeds[] = {""}; static const string testnet_seeds[] = {""};
static const string *seeds = mainnet_seeds; static const string *seeds = mainnet_seeds;

View File

@ -60,7 +60,7 @@ class CDataStream;
class CAutoFile; class CAutoFile;
static const unsigned int MAX_SIZE = 0x02000000; static const unsigned int MAX_SIZE = 0x02000000;
static const int PROTOCOL_VERSION = 180005; static const int PROTOCOL_VERSION = 180006;
// Used to bypass the rule against non-const reference to temporary // Used to bypass the rule against non-const reference to temporary
// where it makes sense with wrappers such as CFlatData or CTxDB // where it makes sense with wrappers such as CFlatData or CTxDB