1 /* Copyright (c) 2012-2021. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef _KADEMLIA_ROUTING_TABLE_HPP
8 #define _KADEMLIA_ROUTING_TABLE_HPP
9 #include "s4u-dht-kademlia.hpp"
15 /* Routing table bucket */
17 unsigned int id_; // bucket id
19 std::deque<unsigned int> nodes_; // Nodes in the bucket.
20 unsigned int getId() const { return id_; }
21 explicit Bucket(unsigned int id) noexcept : id_(id) {}
24 /* Node routing table */
26 unsigned int id_; // node id of the client's routing table
27 std::vector<Bucket> buckets_; // Node bucket list
29 explicit RoutingTable(unsigned int node_id);
30 RoutingTable(const RoutingTable&) = delete;
31 RoutingTable& operator=(const RoutingTable&) = delete;
33 Bucket* findBucket(unsigned int id);
34 const Bucket& getBucketAt(unsigned int pos) const { return buckets_[pos]; }
35 bool contains(unsigned int node_id);
37 } // namespace kademlia