Bitcoin Core  0.20.99
P2P Digital Currency
Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
CAddrInfo Class Reference

Extended statistics about a CAddress. More...

#include <addrman.h>

Inheritance diagram for CAddrInfo:
[legend]
Collaboration diagram for CAddrInfo:
[legend]

Public Member Functions

 SERIALIZE_METHODS (CAddrInfo, obj)
 
 CAddrInfo (const CAddress &addrIn, const CNetAddr &addrSource)
 
 CAddrInfo ()
 
int GetTriedBucket (const uint256 &nKey, const std::vector< bool > &asmap) const
 Calculate in which "tried" bucket this entry belongs. More...
 
int GetNewBucket (const uint256 &nKey, const CNetAddr &src, const std::vector< bool > &asmap) const
 Calculate in which "new" bucket this entry belongs, given a certain source. More...
 
int GetNewBucket (const uint256 &nKey, const std::vector< bool > &asmap) const
 Calculate in which "new" bucket this entry belongs, using its default source. More...
 
int GetBucketPosition (const uint256 &nKey, bool fNew, int nBucket) const
 Calculate in which position of a bucket to store this entry. More...
 
bool IsTerrible (int64_t nNow=GetAdjustedTime()) const
 Determine whether the statistics about this entry are bad enough so that it can just be deleted. More...
 
double GetChance (int64_t nNow=GetAdjustedTime()) const
 Calculate the relative chance this entry should be given when selecting nodes to connect to. More...
 
- Public Member Functions inherited from CAddress
 CAddress ()
 
 CAddress (CService ipIn, ServiceFlags nServicesIn)
 
 SERIALIZE_METHODS (CAddress, obj)
 
- Public Member Functions inherited from CService
 CService ()
 
 CService (const CNetAddr &ip, unsigned short port)
 
 CService (const struct in_addr &ipv4Addr, unsigned short port)
 
 CService (const struct sockaddr_in &addr)
 
unsigned short GetPort () const
 
bool GetSockAddr (struct sockaddr *paddr, socklen_t *addrlen) const
 Obtain the IPv4/6 socket address this represents. More...
 
bool SetSockAddr (const struct sockaddr *paddr)
 
std::vector< unsigned char > GetKey () const
 
std::string ToString () const
 
std::string ToStringPort () const
 
std::string ToStringIPPort () const
 
 CService (const struct in6_addr &ipv6Addr, unsigned short port)
 
 CService (const struct sockaddr_in6 &addr)
 
 SERIALIZE_METHODS (CService, obj)
 
- Public Member Functions inherited from CNetAddr
 CNetAddr ()
 Construct an unspecified IPv6 network address (::/128). More...
 
 CNetAddr (const struct in_addr &ipv4Addr)
 
void SetIP (const CNetAddr &ip)
 
void SetRaw (Network network, const uint8_t *data)
 Set raw IPv4 or IPv6 address (in network byte order) More...
 
bool SetInternal (const std::string &name)
 Try to make this a dummy address that maps the specified name into IPv6 like so: (0xFD + sha256("bitcoin")[0:5]) + sha256(name)[0:10]. More...
 
bool SetSpecial (const std::string &strName)
 Try to make this a dummy address that maps the specified onion address into IPv6 using OnionCat's range and encoding. More...
 
bool IsBindAny () const
 
bool IsIPv4 () const
 
bool IsIPv6 () const
 
bool IsRFC1918 () const
 
bool IsRFC2544 () const
 
bool IsRFC6598 () const
 
bool IsRFC5737 () const
 
bool IsRFC3849 () const
 
bool IsRFC3927 () const
 
bool IsRFC3964 () const
 
bool IsRFC4193 () const
 
bool IsRFC4380 () const
 
bool IsRFC4843 () const
 
bool IsRFC7343 () const
 
bool IsRFC4862 () const
 
bool IsRFC6052 () const
 
bool IsRFC6145 () const
 
bool IsHeNet () const
 
bool IsTor () const
 
bool IsLocal () const
 
bool IsRoutable () const
 
bool IsInternal () const
 
bool IsValid () const
 
enum Network GetNetwork () const
 
std::string ToString () const
 
std::string ToStringIP () const
 
unsigned int GetByte (int n) const
 
uint64_t GetHash () const
 
bool GetInAddr (struct in_addr *pipv4Addr) const
 Try to get our IPv4 address. More...
 
uint32_t GetNetClass () const
 
uint32_t GetLinkedIPv4 () const
 For IPv4, mapped IPv4, SIIT translated IPv4, Teredo, 6to4 tunneled addresses, return the relevant IPv4 address as a uint32. More...
 
bool HasLinkedIPv4 () const
 Whether this address has a linked IPv4 address (see GetLinkedIPv4()). More...
 
uint32_t GetMappedAS (const std::vector< bool > &asmap) const
 
std::vector< unsigned char > GetGroup (const std::vector< bool > &asmap) const
 Get the canonical identifier of our network group. More...
 
int GetReachabilityFrom (const CNetAddr *paddrPartner=nullptr) const
 Calculates a metric for how reachable (*this) is from a given partner. More...
 
 CNetAddr (const struct in6_addr &pipv6Addr, const uint32_t scope=0)
 
bool GetIn6Addr (struct in6_addr *pipv6Addr) const
 Try to get our IPv6 address. More...
 
 SERIALIZE_METHODS (CNetAddr, obj)
 

Public Attributes

int64_t nLastTry {0}
 last try whatsoever by us (memory only) More...
 
int64_t nLastCountAttempt {0}
 last counted attempt (memory only) More...
 
- Public Attributes inherited from CAddress
ServiceFlags nServices {NODE_NONE}
 
uint32_t nTime {TIME_INIT}
 

Private Attributes

CNetAddr source
 where knowledge about this address first came from More...
 
int64_t nLastSuccess {0}
 last successful connection by us More...
 
int nAttempts {0}
 connection attempts since last successful attempt More...
 
int nRefCount {0}
 reference count in new sets (memory only) More...
 
bool fInTried {false}
 in tried set? (memory only) More...
 
int nRandomPos {-1}
 position in vRandom More...
 

Friends

class CAddrMan
 

Additional Inherited Members

- Protected Attributes inherited from CService
uint16_t port
 
- Protected Attributes inherited from CNetAddr
unsigned char ip [16]
 
uint32_t scopeId {0}
 

Detailed Description

Extended statistics about a CAddress.

Definition at line 29 of file addrman.h.

Constructor & Destructor Documentation

◆ CAddrInfo() [1/2]

CAddrInfo::CAddrInfo ( const CAddress addrIn,
const CNetAddr addrSource 
)
inline

Definition at line 67 of file addrman.h.

◆ CAddrInfo() [2/2]

CAddrInfo::CAddrInfo ( )
inline

Definition at line 71 of file addrman.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ GetBucketPosition()

int CAddrInfo::GetBucketPosition ( const uint256 nKey,
bool  fNew,
int  nBucket 
) const

Calculate in which position of a bucket to store this entry.

Definition at line 33 of file addrman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChance()

double CAddrInfo::GetChance ( int64_t  nNow = GetAdjustedTime()) const

Calculate the relative chance this entry should be given when selecting nodes to connect to.

Definition at line 59 of file addrman.cpp.

Here is the caller graph for this function:

◆ GetNewBucket() [1/2]

int CAddrInfo::GetNewBucket ( const uint256 nKey,
const CNetAddr src,
const std::vector< bool > &  asmap 
) const

Calculate in which "new" bucket this entry belongs, given a certain source.

Definition at line 22 of file addrman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNewBucket() [2/2]

int CAddrInfo::GetNewBucket ( const uint256 nKey,
const std::vector< bool > &  asmap 
) const
inline

Calculate in which "new" bucket this entry belongs, using its default source.

Definition at line 82 of file addrman.h.

Here is the call graph for this function:

◆ GetTriedBucket()

int CAddrInfo::GetTriedBucket ( const uint256 nKey,
const std::vector< bool > &  asmap 
) const

Calculate in which "tried" bucket this entry belongs.

Definition at line 12 of file addrman.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsTerrible()

bool CAddrInfo::IsTerrible ( int64_t  nNow = GetAdjustedTime()) const

Determine whether the statistics about this entry are bad enough so that it can just be deleted.

Definition at line 39 of file addrman.cpp.

Here is the caller graph for this function:

◆ SERIALIZE_METHODS()

CAddrInfo::SERIALIZE_METHODS ( CAddrInfo  ,
obj   
)
inline

Definition at line 61 of file addrman.h.

Friends And Related Function Documentation

◆ CAddrMan

friend class CAddrMan
friend

Definition at line 57 of file addrman.h.

Member Data Documentation

◆ fInTried

bool CAddrInfo::fInTried {false}
private

in tried set? (memory only)

Definition at line 52 of file addrman.h.

◆ nAttempts

int CAddrInfo::nAttempts {0}
private

connection attempts since last successful attempt

Definition at line 46 of file addrman.h.

◆ nLastCountAttempt

int64_t CAddrInfo::nLastCountAttempt {0}

last counted attempt (memory only)

Definition at line 36 of file addrman.h.

◆ nLastSuccess

int64_t CAddrInfo::nLastSuccess {0}
private

last successful connection by us

Definition at line 43 of file addrman.h.

◆ nLastTry

int64_t CAddrInfo::nLastTry {0}

last try whatsoever by us (memory only)

Definition at line 33 of file addrman.h.

◆ nRandomPos

int CAddrInfo::nRandomPos {-1}
private

position in vRandom

Definition at line 55 of file addrman.h.

◆ nRefCount

int CAddrInfo::nRefCount {0}
private

reference count in new sets (memory only)

Definition at line 49 of file addrman.h.

◆ source

CNetAddr CAddrInfo::source
private

where knowledge about this address first came from

Definition at line 40 of file addrman.h.


The documentation for this class was generated from the following files: