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:
* regularly revisits known nodes to check their availability
* bans nodes after enough failures, or bad behaviour
* accepts nodes down to protocol version 180004 to request new IP addresses from,
but only reports good (180005) nodes.
* accepts nodes down to protocol version 180005 to request new IP addresses from,
but only reports good (180006) 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.

26
db.h
View File

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

View File

@ -82,17 +82,17 @@ public:
host = optarg;
break;
}
case 'm': {
mbox = optarg;
break;
}
case 'n': {
ns = optarg;
break;
}
case 't': {
int n = strtol(optarg, NULL, 10);
if (n > 0 && n < 1000) nThreads = n;
@ -390,7 +390,7 @@ extern "C" void* ThreadStats(void*) {
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 *seeds = mainnet_seeds;

View File

@ -60,7 +60,7 @@ class CDataStream;
class CAutoFile;
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
// where it makes sense with wrappers such as CFlatData or CTxDB