6#ifndef BITCOIN_ADDRMAN_H
7#define BITCOIN_ADDRMAN_H
18#include <unordered_set>
55 explicit AddressPosition(
bool tried_in,
int multiplicity_in,
int bucket_in,
int position_in)
91 const std::unique_ptr<AddrManImpl>
m_impl;
98 template <
typename Stream>
101 template <
typename Stream>
111 size_t Size(std::optional<Network> net = std::nullopt, std::optional<bool> in_new = std::nullopt)
const;
125 bool Add(
const std::vector<CAddress>& vAddr,
const CNetAddr&
source, std::chrono::seconds time_penalty = 0
s);
163 std::pair<CAddress, NodeSeconds>
Select(
bool new_only =
false,
const std::unordered_set<Network>& networks = {})
const;
175 std::vector<CAddress>
GetAddr(
size_t max_addresses,
size_t max_pct, std::optional<Network> network,
const bool filtered =
true)
const;
186 std::vector<std::pair<AddrInfo, AddressPosition>>
GetEntries(
bool from_tried)
const;
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS
Default for -checkaddrman.
Extended statistics about a CAddress.
Stochastic address manager.
void Connected(const CService &addr, NodeSeconds time=Now< NodeSeconds >())
We have successfully connected to this peer.
std::pair< CAddress, NodeSeconds > Select(bool new_only=false, const std::unordered_set< Network > &networks={}) const
Choose an address to connect to.
const std::unique_ptr< AddrManImpl > m_impl
void Attempt(const CService &addr, bool fCountFailure, NodeSeconds time=Now< NodeSeconds >())
Mark an entry as connection attempted to.
size_t Size(std::optional< Network > net=std::nullopt, std::optional< bool > in_new=std::nullopt) const
Return size information about addrman.
std::optional< AddressPosition > FindAddressEntry(const CAddress &addr)
Test-only function Find the address record in AddrMan and return information about its position.
std::vector< std::pair< AddrInfo, AddressPosition > > GetEntries(bool from_tried) const
Returns an information-location pair for all addresses in the selected addrman table.
void ResolveCollisions()
See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
bool Good(const CService &addr, NodeSeconds time=Now< NodeSeconds >())
Mark an address record as accessible and attempt to move it to addrman's tried table.
void Serialize(Stream &s_) const
void Unserialize(Stream &s_)
AddrMan(const NetGroupManager &netgroupman, bool deterministic, int32_t consistency_check_ratio)
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.
std::vector< CAddress > GetAddr(size_t max_addresses, size_t max_pct, std::optional< Network > network, const bool filtered=true) const
Return all or many randomly selected addresses, optionally by network.
A CService with information about it as peer.
A combination of a network address (CNetAddr) and a (TCP) port.
InvalidAddrManVersionError(std::string msg)
ServiceFlags
nServices flags
Location information for an address in AddrMan.
bool operator==(AddressPosition other)
AddressPosition(bool tried_in, int multiplicity_in, int bucket_in, int position_in)
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds