2018-07-11 13:20:14 +00:00
|
|
|
#ifndef LLARP_DHT_KADEMLIA_HPP
|
|
|
|
#define LLARP_DHT_KADEMLIA_HPP
|
|
|
|
|
2018-12-12 00:48:54 +00:00
|
|
|
#include <dht/key.hpp>
|
2020-02-13 22:19:12 +00:00
|
|
|
#include <router_contact.hpp>
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
|
|
|
struct XorMetric
|
|
|
|
{
|
2019-07-29 13:08:40 +00:00
|
|
|
const Key_t us;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2019-04-24 23:27:31 +00:00
|
|
|
XorMetric(const Key_t& ourKey) : us(ourKey)
|
|
|
|
{
|
|
|
|
}
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
operator()(const Key_t& left, const Key_t& right) const
|
|
|
|
{
|
|
|
|
return (us ^ left) < (us ^ right);
|
2019-04-24 23:27:31 +00:00
|
|
|
}
|
2020-02-13 22:19:12 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
operator()(const RouterContact& left, const RouterContact& right) const
|
|
|
|
{
|
|
|
|
return (left.pubkey ^ us) < (right.pubkey ^ us);
|
|
|
|
}
|
2018-07-11 13:20:14 +00:00
|
|
|
};
|
2018-07-17 04:37:50 +00:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|
2018-07-11 13:20:14 +00:00
|
|
|
#endif
|