Merge bitcoin/bitcoin#30397: refactor: Use designated initializer in test/util/net.cpp

e233ec036d refactor: Use designated initializer (Hodlinator)

Pull request description:

  Block was recently touched (e2d1f84858) and the codebase recently switched to C++20 which allows this to improve robustness.

  Follow-up suggested in https://github.com/bitcoin/bitcoin/pull/29625#discussion_r1664818014

ACKs for top commit:
  maflcko:
    ACK e233ec036d

Tree-SHA512: ce3a18f513421e923710a43c8f97db1badb7ff5c6bdbfd62d9543312d2225731db5c14bef16feb47c43b84fad4dc24485086634b680feba422d2b7b363e13fa6
This commit is contained in:
merge-script 2024-07-11 18:37:19 +01:00
commit e51653985c
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

View File

@ -118,20 +118,20 @@ std::vector<NodeEvictionCandidate> GetRandomNodeEvictionCandidates(int n_candida
candidates.reserve(n_candidates); candidates.reserve(n_candidates);
for (int id = 0; id < n_candidates; ++id) { for (int id = 0; id < n_candidates; ++id) {
candidates.push_back({ candidates.push_back({
/*id=*/id, .id=id,
/*m_connected=*/std::chrono::seconds{random_context.randrange(100)}, .m_connected=std::chrono::seconds{random_context.randrange(100)},
/*m_min_ping_time=*/std::chrono::microseconds{random_context.randrange(100)}, .m_min_ping_time=std::chrono::microseconds{random_context.randrange(100)},
/*m_last_block_time=*/std::chrono::seconds{random_context.randrange(100)}, .m_last_block_time=std::chrono::seconds{random_context.randrange(100)},
/*m_last_tx_time=*/std::chrono::seconds{random_context.randrange(100)}, .m_last_tx_time=std::chrono::seconds{random_context.randrange(100)},
/*fRelevantServices=*/random_context.randbool(), .fRelevantServices=random_context.randbool(),
/*m_relay_txs=*/random_context.randbool(), .m_relay_txs=random_context.randbool(),
/*fBloomFilter=*/random_context.randbool(), .fBloomFilter=random_context.randbool(),
/*nKeyedNetGroup=*/random_context.randrange(100u), .nKeyedNetGroup=random_context.randrange(100u),
/*prefer_evict=*/random_context.randbool(), .prefer_evict=random_context.randbool(),
/*m_is_local=*/random_context.randbool(), .m_is_local=random_context.randbool(),
/*m_network=*/ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())], .m_network=ALL_NETWORKS[random_context.randrange(ALL_NETWORKS.size())],
/*m_noban=*/false, .m_noban=false,
/*m_conn_type=*/ConnectionType::INBOUND, .m_conn_type=ConnectionType::INBOUND,
}); });
} }
return candidates; return candidates;