41 auto randAddr = [&rng]() {
43 memcpy(&addr, rng.
randbytes(
sizeof(addr)).data(),
sizeof(addr));
46 memcpy(&port, rng.
randbytes(
sizeof(port)).data(),
sizeof(port));
53 ret.nTime = Now<NodeSeconds>();
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);
117 (void)addrman.Select();
127 i2p_service.
SetSpecial(
"udhdrtrcetjm5sxzskjyr5ztpeszydbh4dpl3pl4utgqqw2v4jna.b32.i2p");
129 i2p_address.
nTime = Now<NodeSeconds>();
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 NetGroupManager EMPTY_NETGROUPMAN
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
BENCHMARK(AddrManAdd, benchmark::PriorityLevel::HIGH)
static std::vector< CAddress > g_sources
static void AddrManGetAddr(benchmark::Bench &bench)
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.
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(const std::string &addr)
Parse a Tor or I2P address and set this object to it.
A combination of a network address (CNetAddr) and a (TCP) port.
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.