Changeset View
Changeset View
Standalone View
Standalone View
src/addrman.h
Show All 18 Lines | |||||
#include <vector> | #include <vector> | ||||
/** | /** | ||||
* Extended statistics about a CAddress | * Extended statistics about a CAddress | ||||
*/ | */ | ||||
class CAddrInfo : public CAddress { | class CAddrInfo : public CAddress { | ||||
public: | public: | ||||
//! last try whatsoever by us (memory only) | //! last try whatsoever by us (memory only) | ||||
int64_t nLastTry; | int64_t nLastTry{0}; | ||||
//! last counted attempt (memory only) | //! last counted attempt (memory only) | ||||
int64_t nLastCountAttempt; | int64_t nLastCountAttempt{0}; | ||||
private: | private: | ||||
//! where knowledge about this address first came from | //! where knowledge about this address first came from | ||||
CNetAddr source; | CNetAddr source; | ||||
//! last successful connection by us | //! last successful connection by us | ||||
int64_t nLastSuccess; | int64_t nLastSuccess{0}; | ||||
//! connection attempts since last successful attempt | //! connection attempts since last successful attempt | ||||
int nAttempts; | int nAttempts{0}; | ||||
//! reference count in new sets (memory only) | //! reference count in new sets (memory only) | ||||
int nRefCount; | int nRefCount{0}; | ||||
//! in tried set? (memory only) | //! in tried set? (memory only) | ||||
bool fInTried; | bool fInTried{false}; | ||||
//! position in vRandom | //! position in vRandom | ||||
int nRandomPos; | int nRandomPos{-1}; | ||||
friend class CAddrMan; | friend class CAddrMan; | ||||
public: | public: | ||||
ADD_SERIALIZE_METHODS; | ADD_SERIALIZE_METHODS; | ||||
template <typename Stream, typename Operation> | template <typename Stream, typename Operation> | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
READWRITEAS(CAddress, *this); | READWRITEAS(CAddress, *this); | ||||
READWRITE(source); | READWRITE(source); | ||||
READWRITE(nLastSuccess); | READWRITE(nLastSuccess); | ||||
READWRITE(nAttempts); | READWRITE(nAttempts); | ||||
} | } | ||||
void Init() { | |||||
nLastSuccess = 0; | |||||
nLastTry = 0; | |||||
nLastCountAttempt = 0; | |||||
nAttempts = 0; | |||||
nRefCount = 0; | |||||
fInTried = false; | |||||
nRandomPos = -1; | |||||
} | |||||
CAddrInfo(const CAddress &addrIn, const CNetAddr &addrSource) | CAddrInfo(const CAddress &addrIn, const CNetAddr &addrSource) | ||||
: CAddress(addrIn), source(addrSource) { | : CAddress(addrIn), source(addrSource) {} | ||||
Init(); | |||||
} | |||||
CAddrInfo() : CAddress(), source() { Init(); } | CAddrInfo() : CAddress(), source() {} | ||||
//! Calculate in which "tried" bucket this entry belongs | //! Calculate in which "tried" bucket this entry belongs | ||||
int GetTriedBucket(const uint256 &nKey) const; | int GetTriedBucket(const uint256 &nKey) const; | ||||
//! Calculate in which "new" bucket this entry belongs, given a certain | //! Calculate in which "new" bucket this entry belongs, given a certain | ||||
//! source | //! source | ||||
int GetNewBucket(const uint256 &nKey, const CNetAddr &src) const; | int GetNewBucket(const uint256 &nKey, const CNetAddr &src) const; | ||||
▲ Show 20 Lines • Show All 580 Lines • Show Last 20 Lines |