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

Public GIT Repository
Merge branch 'doc' into 'master'
[simgrid.git] / examples / s4u / dht-kademlia / node.hpp
index 504fe40451db23d7cdf2b1db5cc0253ca5bed70c..ab64fa72527a25cc975fd77a24d03e7e2802b1ca 100644 (file)
@@ -4,8 +4,8 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef _KADEMLIA_NODE_HPP
-#define _KADEMLIA_NODE_HPP
+#ifndef KADEMLIA_NODE_HPP
+#define KADEMLIA_NODE_HPP
 #include "answer.hpp"
 #include "message.hpp"
 #include "routing_table.hpp"
@@ -16,11 +16,11 @@ 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;
@@ -34,10 +34,11 @@ public:
   bool findNode(unsigned int id_to_find, bool count_in_stats);
   void randomLookup();
   void handleFindNode(const Message* msg);
+  void displaySuccessRate();
 };
-}
+} // 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);
 
-#endif /* _MSG_EXAMPLES_ROUTING_H */
+#endif /* KADEMLIA_NODE_HPP */