llarp/dht/kademlia.hpp

Namespaces

Name
llarp
[crypto.hpp]
llarp::dht

Classes

Name
struct llarp::dht::XorMetric

Source code

#pragma once

#include "key.hpp"
#include <llarp/router_contact.hpp>

namespace llarp::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 (us ^ left.pubkey.as_array()) < (us ^ right.pubkey.as_array());
    }
  };
}  // namespace llarp::dht

Updated on 2026-04-01 at 23:35:40 +0000