---
title: llarp/dht/kademlia.hpp

---

# llarp/dht/kademlia.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |
| **[llarp::dht](Namespaces/namespacellarp_1_1dht.md)**  |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::dht::XorMetric](Classes/structllarp_1_1dht_1_1XorMetric.md)**  |




## Source code

```cpp
#pragma once

#include "key.hpp"
#include <llarp/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);
      }
    };
  }  // namespace dht
}  // namespace llarp
```


-------------------------------

Updated on 2023-01-27 at 23:09:26 +0000
