41 auto randAddr = [&rng]() {
43 memcpy(&addr, rng.
randbytes(
sizeof(addr)).data(),
sizeof(addr));
46 memcpy(&port, rng.
randbytes(
sizeof(port)).data(),
sizeof(port));
58 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
69 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
100 const auto& address = addrman.
Select();
101 assert(address.first.GetPort() > 0);
127 i2p_service.
SetSpecial(
"udhdrtrcetjm5sxzskjyr5ztpeszydbh4dpl3pl4utgqqw2v4jna.b32.i2p");
131 addrman.
Add({i2p_address}, source);
136 (void)addrman.
Select(
false, {NET_I2P});
147 const auto& addresses = addrman.
GetAddr(2500, 23, std::nullopt);
148 assert(addresses.size() > 0);
154 auto markSomeAsGood = [](
AddrMan& addrman) {
155 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
174 markSomeAsGood(addrman);
static void AddrManSelectByNetwork(benchmark::Bench &bench)
static void AddrManSelectFromAlmostEmpty(benchmark::Bench &bench)
static void FillAddrMan(AddrMan &addrman)
static void AddrManSelect(benchmark::Bench &bench)
static void AddrManAddThenGood(benchmark::Bench &bench)
static constexpr size_t NUM_SOURCES
static constexpr uint32_t ADDRMAN_CONSISTENCY_CHECK_RATIO
static std::vector< CAddress > g_sources
static void AddrManGetAddr(benchmark::Bench &bench)
static auto EMPTY_NETGROUPMAN
static constexpr size_t NUM_ADDRESSES_PER_SOURCE
static void CreateAddresses()
static void AddAddressesToAddrMan(AddrMan &addrman)
static void AddrManAdd(benchmark::Bench &bench)
static std::vector< std::vector< CAddress > > g_addresses
Stochastic address manager.
std::pair< CAddress, NodeSeconds > Select(bool new_only=false, const std::unordered_set< Network > &networks={}) const
Choose an address to connect to.
std::vector< CAddress > GetAddr(size_t max_addresses, size_t max_pct, std::optional< Network > network, bool filtered=true) const
Return all or many randomly selected addresses, optionally by network.
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.
A CService with information about it as peer.
NodeSeconds nTime
Always included in serialization. The behavior is unspecified if the value is not representable as ui...
bool SetSpecial(std::string_view addr)
Parse a Tor or I2P address and set this object to it.
A combination of a network address (CNetAddr) and a (TCP) port.
static NetGroupManager NoAsmap()
std::vector< B > randbytes(size_t len) noexcept
Generate random bytes.
Main entry point to nanobench's benchmarking facility.
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
std::vector< CNetAddr > LookupHost(const std::string &name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
Resolve a host string to its corresponding network addresses.
std::vector< CService > Lookup(const std::string &name, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function)
Resolve a service string to its corresponding service.
T Now()
Return the current time point cast to the given precision.