1 /* Copyright (c) 2012-2018. 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_ANSWER_HPP_
8 #define _KADEMLIA_ANSWER_HPP_
11 #include "routing_table.hpp"
15 bool sortbydistance(const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b);
17 /* Node query answer. contains the elements closest to the id given. */
19 unsigned int destination_id_;
20 unsigned int size_ = 0;
23 std::vector<std::pair<unsigned int, unsigned int>> nodes;
24 explicit Answer(unsigned int destination_id) : destination_id_(destination_id) {}
25 virtual ~Answer() = default;
26 unsigned int getDestinationId() { return destination_id_; }
27 unsigned int getSize() { return size_; }
29 unsigned int merge(Answer* a);
31 bool destinationFound();
32 void addBucket(kademlia::Bucket* bucket);