lokinet/llarp/dht/kademlia.hpp

34 lines
625 B
C++
Raw Normal View History

#ifndef LLARP_DHT_KADEMLIA_HPP
#define LLARP_DHT_KADEMLIA_HPP
2018-12-12 00:48:54 +00:00
#include <dht/key.hpp>
#include <router_contact.hpp>
namespace llarp
{
namespace dht
{
struct XorMetric
{
const Key_t us;
XorMetric(const Key_t& ourKey) : us(ourKey)
{
}
bool
operator()(const Key_t& left, const Key_t& right) const
{
return (us ^ left) < (us ^ right);
}
bool
operator()(const RouterContact& left, const RouterContact& right) const
{
return (left.pubkey ^ us) < (right.pubkey ^ us);
}
};
2018-07-17 04:37:50 +00:00
} // namespace dht
} // namespace llarp
#endif