6 #ifndef BITCOIN_ADDRMAN_H
7 #define BITCOIN_ADDRMAN_H
69 const std::unique_ptr<AddrManImpl>
m_impl;
72 AddrMan(std::vector<bool> asmap, int32_t consistency_check_ratio);
76 template <
typename Stream>
void Serialize(Stream &s_)
const;
78 template <
typename Stream>
void Unserialize(Stream &s_);
85 int64_t nTimePenalty = 0);
88 void Good(
const CService &addr,
bool test_before_evict =
true,
115 std::pair<CAddress, int64_t>
Select(
bool newOnly =
false)
const;
130 std::vector<CAddress>
GetAddr(
size_t max_addresses,
size_t max_pct,
131 std::optional<Network> network)
const;
150 const std::vector<bool> &
GetAsmap()
const;
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS
Default for -checkaddrman.
Stochastic address manager.
friend class AddrManCorrupted
std::pair< CAddress, int64_t > SelectTriedCollision()
Randomly select an address in the tried table that another address is attempting to evict.
void MakeDeterministic()
Ensure that bucket placement is always the same for testing purposes.
const std::unique_ptr< AddrManImpl > m_impl
std::vector< CAddress > GetAddr(size_t max_addresses, size_t max_pct, std::optional< Network > network) const
Return all or many randomly selected addresses, optionally by network.
const std::vector< bool > & GetAsmap() const
bool Add(const std::vector< CAddress > &vAddr, const CNetAddr &source, int64_t nTimePenalty=0)
Add addresses to addrman's new table.
void ResolveCollisions()
See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
void Connected(const CService &addr, int64_t nTime=GetAdjustedTime())
We have successfully connected to this peer.
void Attempt(const CService &addr, bool fCountFailure, int64_t nTime=GetAdjustedTime())
Mark an entry as connection attempted to.
AddrMan(std::vector< bool > asmap, int32_t consistency_check_ratio)
void Serialize(Stream &s_) const
size_t size() const
Return the number of (unique) addresses in all tables.
void Unserialize(Stream &s_)
std::pair< CAddress, int64_t > Select(bool newOnly=false) const
Choose an address to connect to.
void SetServices(const CService &addr, ServiceFlags nServices)
Update an entry's service bits.
void Good(const CService &addr, bool test_before_evict=true, int64_t nTime=GetAdjustedTime())
Mark an entry as accessible, possibly moving it from "new" to "tried".
A combination of a network address (CNetAddr) and a (TCP) port.
InvalidAddrManVersionError(std::string msg)
ServiceFlags
nServices flags.
int64_t GetAdjustedTime()