Bitcoin Core  27.99.0
P2P Digital Currency
Public Member Functions | Public Attributes | List of all members
AddrInfo Class Reference

Extended statistics about a CAddress. More...

#include <addrman_impl.h>

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

Public Member Functions

 SERIALIZE_METHODS (AddrInfo, obj)
 
 AddrInfo (const CAddress &addrIn, const CNetAddr &addrSource)
 
 AddrInfo ()
 
int GetTriedBucket (const uint256 &nKey, const NetGroupManager &netgroupman) const
 Calculate in which "tried" bucket this entry belongs. More...
 
int GetNewBucket (const uint256 &nKey, const CNetAddr &src, const NetGroupManager &netgroupman) const
 Calculate in which "new" bucket this entry belongs, given a certain source. More...
 
int GetNewBucket (const uint256 &nKey, const NetGroupManager &netgroupman) const
 Calculate in which "new" bucket this entry belongs, using its default source. More...
 
int GetBucketPosition (const uint256 &nKey, bool fNew, int bucket) const
 Calculate in which position of a bucket to store this entry. More...
 
bool IsTerrible (NodeSeconds now=Now< NodeSeconds >()) const
 Determine whether the statistics about this entry are bad enough so that it can just be deleted. More...
 
double GetChance (NodeSeconds now=Now< NodeSeconds >()) 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)
 
 CAddress (CService ipIn, ServiceFlags nServicesIn, NodeSeconds time)
 
 SERIALIZE_METHODS_PARAMS (CAddress, obj, SerParams, params)
 
- Public Member Functions inherited from CService
 CService ()
 
 CService (const CNetAddr &ip, uint16_t port)
 
 CService (const struct in_addr &ipv4Addr, uint16_t port)
 
 CService (const struct sockaddr_in &addr)
 
uint16_t 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)
 
sa_family_t GetSAFamily () const
 Get the address family. More...
 
std::vector< unsigned char > GetKey () const
 
std::string ToStringAddrPort () const
 
 CService (const struct in6_addr &ipv6Addr, uint16_t 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 SetLegacyIPv6 (Span< const uint8_t > ipv6)
 Set from a legacy IPv6 address. More...
 
bool SetInternal (const std::string &name)
 Create an "internal" address that represents a name or FQDN. More...
 
bool SetSpecial (const std::string &addr)
 Parse a Tor or I2P address and set this object to it. 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 IsI2P () const
 
bool IsCJDNS () const
 
bool HasCJDNSPrefix () const
 
bool IsLocal () const
 
bool IsRoutable () const
 
bool IsInternal () const
 
bool IsValid () const
 
bool IsPrivacyNet () const
 Whether this object is a privacy network. More...
 
bool IsAddrV1Compatible () const
 Check if the current object can be serialized in pre-ADDRv2/BIP155 format. More...
 
enum Network GetNetwork () const
 
std::string ToStringAddr () const
 
bool GetInAddr (struct in_addr *pipv4Addr) const
 Try to get our IPv4 address. More...
 
Network 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...
 
std::vector< unsigned char > GetAddrBytes () const
 
int GetReachabilityFrom (const CNetAddr &paddrPartner) 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 (or CJDNS) address. More...
 
bool IsRelayable () const
 Whether this address should be relayed to other peers even if we can't reach it ourselves. More...
 
template<typename Stream >
void Serialize (Stream &s) const
 Serialize to a stream. More...
 
template<typename Stream >
void Unserialize (Stream &s)
 Unserialize from a stream. More...
 

Public Attributes

NodeSeconds m_last_try {0s}
 last try whatsoever by us (memory only) More...
 
NodeSeconds m_last_count_attempt {0s}
 last counted attempt (memory only) More...
 
CNetAddr source
 where knowledge about this address first came from More...
 
NodeSeconds m_last_success {0s}
 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...
 
- Public Attributes inherited from CAddress
NodeSeconds nTime {TIME_INIT}
 Always included in serialization. The behavior is unspecified if the value is not representable as uint32_t. More...
 
ServiceFlags nServices {NODE_NONE}
 Serialized as uint64_t in V1, and as CompactSize in V2. More...
 

Additional Inherited Members

- Public Types inherited from CAddress
enum class  Format { Disk , Network }
 
- Public Types inherited from CNetAddr
enum class  Encoding { V1 , V2 }
 
enum  BIP155Network : uint8_t {
  IPV4 = 1 , IPV6 = 2 , TORV2 = 3 , TORV3 = 4 ,
  I2P = 5 , CJDNS = 6
}
 BIP155 network ids recognized by this software. More...
 
- Static Public Attributes inherited from CAddress
static constexpr SerParams V1_NETWORK {{CNetAddr::Encoding::V1}, Format::Network}
 
static constexpr SerParams V2_NETWORK {{CNetAddr::Encoding::V2}, Format::Network}
 
static constexpr SerParams V1_DISK {{CNetAddr::Encoding::V1}, Format::Disk}
 
static constexpr SerParams V2_DISK {{CNetAddr::Encoding::V2}, Format::Disk}
 
- Static Public Attributes inherited from CNetAddr
static constexpr SerParams V1 {Encoding::V1}
 
static constexpr SerParams V2 {Encoding::V2}
 
- Protected Attributes inherited from CService
uint16_t port
 
- Protected Attributes inherited from CNetAddr
prevector< ADDR_IPV6_SIZE, uint8_t > m_addr {ADDR_IPV6_SIZE, 0x0}
 Raw representation of the network address. More...
 
Network m_net {NET_IPV6}
 Network to which this address belongs. More...
 
uint32_t m_scope_id {0}
 Scope id if scoped/link-local IPV6 address. More...
 

Detailed Description

Extended statistics about a CAddress.

Definition at line 39 of file addrman_impl.h.

Constructor & Destructor Documentation

◆ AddrInfo() [1/2]

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

Definition at line 71 of file addrman_impl.h.

◆ AddrInfo() [2/2]

AddrInfo::AddrInfo ( )
inline

Definition at line 75 of file addrman_impl.h.

Member Function Documentation

◆ GetBucketPosition()

int AddrInfo::GetBucketPosition ( const uint256 nKey,
bool  fNew,
int  bucket 
) const

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

Definition at line 65 of file addrman.cpp.

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

◆ GetChance()

double AddrInfo::GetChance ( NodeSeconds  now = Now<NodeSeconds>()) const

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

Definition at line 96 of file addrman.cpp.

◆ GetNewBucket() [1/2]

int AddrInfo::GetNewBucket ( const uint256 nKey,
const CNetAddr src,
const NetGroupManager netgroupman 
) const

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

Definition at line 57 of file addrman.cpp.

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

◆ GetNewBucket() [2/2]

int AddrInfo::GetNewBucket ( const uint256 nKey,
const NetGroupManager netgroupman 
) const
inline

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

Definition at line 86 of file addrman_impl.h.

Here is the call graph for this function:

◆ GetTriedBucket()

int AddrInfo::GetTriedBucket ( const uint256 nKey,
const NetGroupManager netgroupman 
) const

Calculate in which "tried" bucket this entry belongs.

Definition at line 50 of file addrman.cpp.

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

◆ IsTerrible()

bool AddrInfo::IsTerrible ( NodeSeconds  now = Now<NodeSeconds>()) const

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

Definition at line 71 of file addrman.cpp.

Here is the caller graph for this function:

◆ SERIALIZE_METHODS()

AddrInfo::SERIALIZE_METHODS ( AddrInfo  ,
obj   
)
inline

Definition at line 66 of file addrman_impl.h.

Here is the call graph for this function:

Member Data Documentation

◆ fInTried

bool AddrInfo::fInTried {false}

in tried set? (memory only)

Definition at line 61 of file addrman_impl.h.

◆ m_last_count_attempt

NodeSeconds AddrInfo::m_last_count_attempt {0s}

last counted attempt (memory only)

Definition at line 46 of file addrman_impl.h.

◆ m_last_success

NodeSeconds AddrInfo::m_last_success {0s}

last successful connection by us

Definition at line 52 of file addrman_impl.h.

◆ m_last_try

NodeSeconds AddrInfo::m_last_try {0s}

last try whatsoever by us (memory only)

Definition at line 43 of file addrman_impl.h.

◆ nAttempts

int AddrInfo::nAttempts {0}

connection attempts since last successful attempt

Definition at line 55 of file addrman_impl.h.

◆ nRandomPos

int AddrInfo::nRandomPos {-1}
mutable

position in vRandom

Definition at line 64 of file addrman_impl.h.

◆ nRefCount

int AddrInfo::nRefCount {0}

reference count in new sets (memory only)

Definition at line 58 of file addrman_impl.h.

◆ source

CNetAddr AddrInfo::source

where knowledge about this address first came from

Definition at line 49 of file addrman_impl.h.


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