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_);
95 std::chrono::seconds time_penalty = 0s);
98 void Good(
const CService &addr,
bool test_before_evict =
true,
125 std::pair<CAddress, NodeSeconds>
Select(
bool newOnly =
false)
const;
140 std::vector<CAddress>
GetAddr(
size_t max_addresses,
size_t max_pct,
141 std::optional<Network> network)
const;
160 const std::vector<bool> &
GetAsmap()
const;
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS
Default for -checkaddrman.
Stochastic address manager.
friend class AddrManCorrupted
void Connected(const CService &addr, NodeSeconds time=Now< NodeSeconds >())
We have successfully connected to this peer.
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
void Attempt(const CService &addr, bool fCountFailure, NodeSeconds time=Now< NodeSeconds >())
Mark an entry as connection attempted to.
std::pair< CAddress, NodeSeconds > Select(bool newOnly=false) const
Choose an address to connect to.
void ResolveCollisions()
See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
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_)
void Good(const CService &addr, bool test_before_evict=true, NodeSeconds time=Now< NodeSeconds >())
Mark an entry as accessible, possibly moving it from "new" to "tried".
std::pair< CAddress, NodeSeconds > SelectTriedCollision()
Randomly select an address in the tried table that another address is attempting to evict.
bool Add(const std::vector< CAddress > &vAddr, const CNetAddr &source, std::chrono::seconds time_penalty=0s)
Attempt to add one or more addresses to addrman's new table.
void SetServices(const CService &addr, ServiceFlags nServices)
Update an entry's service bits.
A combination of a network address (CNetAddr) and a (TCP) port.
InvalidAddrManVersionError(std::string msg)
Implement std::hash so RCUPtr can be used as a key for maps or sets.
ServiceFlags
nServices flags.
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds