29 size_t size(sa_family_t family)
const {
30 return cache(family).count();
33 return size(AF_INET) + size(AF_INET6);
36 Sp<Node> getNode(
const InfoHash&
id, sa_family_t family);
37 Sp<Node> getNode(
const InfoHash&
id,
const SockAddr&, time_point now,
bool confirmed,
bool client=
false);
38 std::vector<Sp<Node>> getCachedNodes(
const InfoHash&
id, sa_family_t sa_f,
size_t count)
const;
51 class NodeMap :
private std::map<InfoHash, std::weak_ptr<Node>> {
53 Sp<Node> getNode(
const InfoHash&
id);
54 Sp<Node> getNode(
const InfoHash&
id,
const SockAddr&, time_point now,
bool confirmed,
bool client, std::mt19937_64& rd);
55 std::vector<Sp<Node>> getCachedNodes(
const InfoHash&
id,
size_t count)
const;
59 size_t count()
const {
return size(); }
61 size_t cleanup_counter {0};
64 const NodeMap& cache(sa_family_t af)
const {
return af == AF_INET ? cache_4 : cache_6; }
65 NodeMap& cache(sa_family_t af) {
return af == AF_INET ? cache_4 : cache_6; }