19 Bucket(sa_family_t af,
const InfoHash& f = {}, time_point t = time_point::min())
27 time_point time {time_point::min()};
28 std::list<Sp<Node>> nodes {};
35 void connectivityChanged()
37 time = time_point::min();
38 for (
auto& node : nodes)
39 node->setTime(time_point::min());
46 using std::list<
Bucket>::list;
48 time_point grow_time {time_point::min()};
49 bool is_client {
false};
51 InfoHash middle(
const RoutingTable::const_iterator&)
const;
53 std::vector<Sp<Node>> findClosestNodes(
const InfoHash
id, time_point now,
size_t count = TARGET_NODES)
const;
55 RoutingTable::iterator findBucket(
const InfoHash&
id);
56 RoutingTable::const_iterator findBucket(
const InfoHash&
id)
const;
61 inline bool contains(
const RoutingTable::const_iterator& bucket,
const InfoHash&
id)
const
63 return InfoHash::cmp(bucket->first,
id) <= 0
64 && (std::next(bucket) == end() || InfoHash::cmp(
id, std::next(bucket)->first) < 0);
70 inline bool isEmpty()
const {
return empty() || (size() == 1 && front().nodes.empty()); }
72 void connectivityChanged(
const time_point& now)
76 b.connectivityChanged();
80 const Sp<Node>& node,
int comfirm,
const time_point& now,
const InfoHash& myid, net::NetworkEngine& ne);
85 InfoHash
randomId(
const RoutingTable::const_iterator& bucket, std::mt19937_64& rd)
const;
87 unsigned depth(
const RoutingTable::const_iterator& bucket)
const;
92 bool split(
const RoutingTable::iterator& b);