33 auto randAddr = [&rng]() {
35 memcpy(&addr, rng.
randbytes(
sizeof(addr)).data(),
sizeof(addr));
38 memcpy(&port, rng.
randbytes(
sizeof(port)).data(),
sizeof(port));
45 ret.
nTime = Now<NodeSeconds>();
50 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
60 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
76 AddrMan addrman( std::vector<bool>(),
86 AddrMan addrman( std::vector<bool>(),
92 const auto &address = addrman.
Select();
93 assert(address.first.GetPort() > 0);
98 AddrMan addrman( std::vector<bool>(),
104 const auto &addresses =
107 assert(addresses.size() > 0);
112 auto markSomeAsGood = [](
AddrMan &addrman) {
113 for (
size_t source_i = 0; source_i <
NUM_SOURCES; ++source_i) {
133 AddrMan addrman(std::vector<bool>(),
137 markSomeAsGood(addrman);
static void FillAddrMan(AddrMan &addrman)
static void AddrManSelect(benchmark::Bench &bench)
static void AddrManAddThenGood(benchmark::Bench &bench)
static constexpr size_t NUM_SOURCES
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.
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.
std::pair< CAddress, NodeSeconds > Select(bool newOnly=false) const
Choose an address to connect to.
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, except in the network format on INIT_PROTO_VERSION.
A combination of a network address (CNetAddr) and a (TCP) port.
std::vector< uint8_t > randbytes(size_t len)
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.