A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update copyright lines with new year.
[simgrid.git]
/
examples
/
s4u
/
dht-kademlia
/
node.cpp
diff --git
a/examples/s4u/dht-kademlia/node.cpp
b/examples/s4u/dht-kademlia/node.cpp
index
2f7a756
..
fa61fef
100644
(file)
--- a/
examples/s4u/dht-kademlia/node.cpp
+++ b/
examples/s4u/dht-kademlia/node.cpp
@@
-1,4
+1,4
@@
-/* Copyright (c) 2010-20
19
. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-20
20
. The SimGrid Team. All rights reserved. */
/* 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. */
/* 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. */
@@
-11,7
+11,7
@@
XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia_node, "Messages specific for this example"
namespace kademlia {
static void destroy(void* message)
{
namespace kademlia {
static void destroy(void* message)
{
- Message* msg = static_cast<Message*>(message);
+
const
Message* msg = static_cast<Message*>(message);
delete msg->answer_;
delete msg;
}
delete msg->answer_;
delete msg;
}
@@
-22,7
+22,7
@@
static void destroy(void* message)
*/
bool Node::join(unsigned int known_id)
{
*/
bool Node::join(unsigned int known_id)
{
- Answer* node_list;
+
const
Answer* node_list;
unsigned int i;
bool got_answer = false;
unsigned int i;
bool got_answer = false;
@@
-41,7
+41,7
@@
bool Node::join(unsigned int known_id)
XBT_DEBUG("Received an answer from the node I know.");
got_answer = true;
// retrieve the node list and ping them.
XBT_DEBUG("Received an answer from the node I know.");
got_answer = true;
// retrieve the node list and ping them.
- Message* msg = static_cast<Message*>(received_msg);
+
const
Message* msg = static_cast<Message*>(received_msg);
node_list = msg->answer_;
if (node_list) {
for (auto contact : node_list->nodes)
node_list = msg->answer_;
if (node_list) {
for (auto contact : node_list->nodes)
@@
-93,7
+93,7
@@
void Node::sendFindNode(unsigned int id, unsigned int destination)
* Sends to the best "KADEMLIA_ALPHA" nodes in the "node_list" array a "FIND_NODE" request, to ask them for their best
* nodes
*/
* Sends to the best "KADEMLIA_ALPHA" nodes in the "node_list" array a "FIND_NODE" request, to ask them for their best
* nodes
*/
-unsigned int Node::sendFindNodeToBest(Answer* node_list)
+unsigned int Node::sendFindNodeToBest(
const
Answer* node_list)
{
unsigned int i = 0;
unsigned int j = 0;
{
unsigned int i = 0;
unsigned int j = 0;
@@
-206,7
+206,7
@@
bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
receive_comm = mailbox->get_async(&received_msg);
if (receive_comm->test()) {
receive_comm = mailbox->get_async(&received_msg);
if (receive_comm->test()) {
- Message* msg = static_cast<Message*>(received_msg);
+
const
Message* msg = static_cast<Message*>(received_msg);
// Check if what we have received is what we are looking for.
if (msg->answer_ && msg->answer_->getDestinationId() == id_to_find) {
routingTableUpdate(msg->sender_id_);
// Check if what we have received is what we are looking for.
if (msg->answer_ && msg->answer_->getDestinationId() == id_to_find) {
routingTableUpdate(msg->sender_id_);
@@
-262,13
+262,13
@@
bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
void Node::randomLookup()
{
unsigned int id_to_look = RANDOM_LOOKUP_NODE; // Totally random.
void Node::randomLookup()
{
unsigned int id_to_look = RANDOM_LOOKUP_NODE; // Totally random.
- /* TODO: Use some pseudo-random generator
like RngStream
. */
+ /* TODO: Use some pseudo-random generator. */
XBT_DEBUG("I'm doing a random lookup");
findNode(id_to_look, true);
}
/** @brief Handles the answer to an incoming "find_node" task */
XBT_DEBUG("I'm doing a random lookup");
findNode(id_to_look, true);
}
/** @brief Handles the answer to an incoming "find_node" task */
-void Node::handleFindNode(Message* msg)
+void Node::handleFindNode(
const
Message* msg)
{
routingTableUpdate(msg->sender_id_);
XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->get_cname(),
{
routingTableUpdate(msg->sender_id_);
XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->get_cname(),