-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include <set>
namespace kademlia {
-bool sortbydistance(const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b);
-
/* Node query answer. contains the elements closest to the id given. */
class Answer {
unsigned int destination_id_;
- unsigned int size_ = 0;
+ std::vector<std::pair<unsigned int, unsigned int>> nodes_;
public:
- std::vector<std::pair<unsigned int, unsigned int>> nodes;
explicit Answer(unsigned int destination_id) : destination_id_(destination_id) {}
virtual ~Answer() = default;
- unsigned int getDestinationId() { return destination_id_; }
- unsigned int getSize() { return size_; }
+ unsigned int getDestinationId() const { return destination_id_; }
+ size_t getSize() const { return nodes_.size(); }
+ const std::vector<std::pair<unsigned int, unsigned int>>& getNodes() const { return nodes_; }
void print();
- unsigned int merge(Answer* a);
+ unsigned int merge(const Answer* a);
void trim();
- bool destinationFound();
- void addBucket(kademlia::Bucket* bucket);
+ bool destinationFound() const;
+ void addBucket(const kademlia::Bucket* bucket);
};
}