|
|
@ -46,6 +46,8 @@ class CAddrReport { |
|
|
|
public: |
|
|
|
public: |
|
|
|
CIPPort ip; |
|
|
|
CIPPort ip; |
|
|
|
int clientVersion; |
|
|
|
int clientVersion; |
|
|
|
|
|
|
|
double uptime[5]; |
|
|
|
|
|
|
|
std::string clientSubVersion; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -60,9 +62,11 @@ private: |
|
|
|
CAddrStat stat8H; |
|
|
|
CAddrStat stat8H; |
|
|
|
CAddrStat stat1D; |
|
|
|
CAddrStat stat1D; |
|
|
|
CAddrStat stat1W; |
|
|
|
CAddrStat stat1W; |
|
|
|
|
|
|
|
CAddrStat stat1M; |
|
|
|
int clientVersion; |
|
|
|
int clientVersion; |
|
|
|
int total; |
|
|
|
int total; |
|
|
|
int success; |
|
|
|
int success; |
|
|
|
|
|
|
|
std::string clientSubVersion; |
|
|
|
public: |
|
|
|
public: |
|
|
|
CAddrInfo() : services(0), lastTry(0), ourLastTry(0), ignoreTill(0), clientVersion(0), total(0), success(0) {} |
|
|
|
CAddrInfo() : services(0), lastTry(0), ourLastTry(0), ignoreTill(0), clientVersion(0), total(0), success(0) {} |
|
|
|
|
|
|
|
|
|
|
@ -70,6 +74,12 @@ public: |
|
|
|
CAddrReport ret; |
|
|
|
CAddrReport ret; |
|
|
|
ret.ip = ip; |
|
|
|
ret.ip = ip; |
|
|
|
ret.clientVersion = clientVersion; |
|
|
|
ret.clientVersion = clientVersion; |
|
|
|
|
|
|
|
ret.clientSubVersion = clientSubVersion; |
|
|
|
|
|
|
|
ret.uptime[0] = stat2H.reliability; |
|
|
|
|
|
|
|
ret.uptime[1] = stat8H.reliability; |
|
|
|
|
|
|
|
ret.uptime[2] = stat1D.reliability; |
|
|
|
|
|
|
|
ret.uptime[3] = stat1W.reliability; |
|
|
|
|
|
|
|
ret.uptime[4] = stat1M.reliability; |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -109,7 +119,7 @@ public: |
|
|
|
friend class CAddrDb; |
|
|
|
friend class CAddrDb; |
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_SERIALIZE ( |
|
|
|
IMPLEMENT_SERIALIZE ( |
|
|
|
unsigned char version = 0; |
|
|
|
unsigned char version = 2; |
|
|
|
READWRITE(version); |
|
|
|
READWRITE(version); |
|
|
|
READWRITE(ip); |
|
|
|
READWRITE(ip); |
|
|
|
READWRITE(services); |
|
|
|
READWRITE(services); |
|
|
@ -123,9 +133,16 @@ public: |
|
|
|
READWRITE(stat8H); |
|
|
|
READWRITE(stat8H); |
|
|
|
READWRITE(stat1D); |
|
|
|
READWRITE(stat1D); |
|
|
|
READWRITE(stat1W); |
|
|
|
READWRITE(stat1W); |
|
|
|
|
|
|
|
if (version >= 1) |
|
|
|
|
|
|
|
READWRITE(stat1M); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
if (!fWrite) |
|
|
|
|
|
|
|
*((CAddrStat*)(&stat1M)) = stat1W; |
|
|
|
READWRITE(total); |
|
|
|
READWRITE(total); |
|
|
|
READWRITE(success); |
|
|
|
READWRITE(success); |
|
|
|
READWRITE(clientVersion); |
|
|
|
READWRITE(clientVersion); |
|
|
|
|
|
|
|
if (version >= 2) |
|
|
|
|
|
|
|
READWRITE(clientSubVersion); |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
}; |
|
|
|
}; |
|
|
@ -157,20 +174,20 @@ private: |
|
|
|
std::deque<int> ourId; // sequence of tried nodes, in order we have tried connecting to them (c,d)
|
|
|
|
std::deque<int> ourId; // sequence of tried nodes, in order we have tried connecting to them (c,d)
|
|
|
|
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)
|
|
|
|
std::map<CIPPort, time_t> banned; // nodes that are banned, with their unban time (a)
|
|
|
|
|
|
|
|
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
|
|
|
|
bool Get_(CIPPort &ip, int& wait); // get an IP to test (must call Good_, Bad_, or Skipped_ on result afterwards)
|
|
|
|
bool Get_(CIPPort &ip, int& wait); // get an IP to test (must call Good_, Bad_, or Skipped_ on result afterwards)
|
|
|
|
void Good_(const CIPPort &ip, int clientV); // mark an IP as good (must have been returned by Get_)
|
|
|
|
void Good_(const CIPPort &ip, int clientV, std::string clientSV); // mark an IP as good (must have been returned by Get_)
|
|
|
|
void Bad_(const CIPPort &ip, int ban); // mark an IP as bad (and optionally ban it) (must have been returned by Get_)
|
|
|
|
void Bad_(const CIPPort &ip, int ban); // mark an IP as bad (and optionally ban it) (must have been returned by Get_)
|
|
|
|
void Skipped_(const CIPPort &ip); // mark an IP as skipped (must have been returned by Get_)
|
|
|
|
void Skipped_(const CIPPort &ip); // mark an IP as skipped (must have been returned by Get_)
|
|
|
|
int Lookup_(const CIPPort &ip); // look up id of an IP
|
|
|
|
int Lookup_(const CIPPort &ip); // look up id of an IP
|
|
|
|
void GetIPs_(std::set<CIP>& ips, int max, bool fOnlyIPv4); // get a random set of IPs (shared lock only)
|
|
|
|
void GetIPs_(std::set<CIP>& ips, int max, bool fOnlyIPv4); // get a random set of IPs (shared lock only)
|
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
std::map<CIPPort, time_t> banned; // nodes that are banned, with their unban time (a)
|
|
|
|
|
|
|
|
|
|
|
|
void GetStats(CAddrDbStats &stats) { |
|
|
|
void GetStats(CAddrDbStats &stats) { |
|
|
|
SHARED_CRITICAL_BLOCK(cs) { |
|
|
|
SHARED_CRITICAL_BLOCK(cs) { |
|
|
@ -255,9 +272,9 @@ public: |
|
|
|
for (int i=0; i<vAddr.size(); i++) |
|
|
|
for (int i=0; i<vAddr.size(); i++) |
|
|
|
Add_(vAddr[i], fForce); |
|
|
|
Add_(vAddr[i], fForce); |
|
|
|
} |
|
|
|
} |
|
|
|
void Good(const CIPPort &addr, int clientVersion) { |
|
|
|
void Good(const CIPPort &addr, int clientVersion, std::string clientSubVersion) { |
|
|
|
CRITICAL_BLOCK(cs) |
|
|
|
CRITICAL_BLOCK(cs) |
|
|
|
Good_(addr, clientVersion); |
|
|
|
Good_(addr, clientVersion, clientSubVersion); |
|
|
|
} |
|
|
|
} |
|
|
|
void Skipped(const CIPPort &addr) { |
|
|
|
void Skipped(const CIPPort &addr) { |
|
|
|
CRITICAL_BLOCK(cs) |
|
|
|
CRITICAL_BLOCK(cs) |
|
|
|