]> AND Public Git Repository - simgrid.git/blobdiff - examples/s4u/dht-kademlia/node.hpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix build on 32bits
[simgrid.git] / examples / s4u / dht-kademlia / node.hpp
index dc36ae20fbab5373e0ea940247bc96e4456512b1..f65106c77a8adadea5b6432fb672201d4b83c4c5 100644 (file)
@@ -16,26 +16,27 @@ namespace kademlia {
 class Node {
   unsigned int id_;              // node id - 160 bits
   RoutingTable table;            // node routing table
+  unsigned int find_node_success = 0; // Number of find_node which have succeeded.
+  unsigned int find_node_failed  = 0; // Number of find_node which have failed.
 public:
   simgrid::s4u::CommPtr receive_comm = nullptr;
   void* received_msg             = nullptr;
-  unsigned int find_node_success = 0; // Number of find_node which have succeeded.
-  unsigned int find_node_failed  = 0; // Number of find_node which have failed.
   explicit Node(unsigned int node_id) : id_(node_id), table(node_id) {}
   Node(const Node&) = delete;
   Node& operator=(const Node&) = delete;
-  unsigned int getId() { return id_; }
+  unsigned int getId() const { return id_; }
 
   bool join(unsigned int known_id);
-  void sendFindNode(unsigned int id, unsigned int destination);
-  unsigned int sendFindNodeToBest(const Answer* node_list);
+  void sendFindNode(unsigned int id, unsigned int destination) const;
+  unsigned int sendFindNodeToBest(const Answer* node_list) const;
   void routingTableUpdate(unsigned int id);
   Answer* findClosest(unsigned int destination_id);
   bool findNode(unsigned int id_to_find, bool count_in_stats);
   void randomLookup();
   void handleFindNode(const Message* msg);
+  void displaySuccessRate() const;
 };
-}
+} // namespace kademlia
 // identifier functions
 unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix);
 unsigned int get_node_prefix(unsigned int id, unsigned int nb_bits);