---
title: llarp/dht/messages/findrouter.hpp

---

# llarp/dht/messages/findrouter.hpp



## Namespaces

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

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::dht::FindRouterMessage](Classes/structllarp_1_1dht_1_1FindRouterMessage.md)**  |
| struct | **[llarp::dht::RelayedFindRouterMessage](Classes/structllarp_1_1dht_1_1RelayedFindRouterMessage.md)** <br>variant of [FindRouterMessage](Classes/structllarp_1_1dht_1_1FindRouterMessage.md) relayed via path  |




## Source code

```cpp
#pragma once
#include <llarp/dht/message.hpp>

namespace llarp
{
  namespace dht
  {
    struct FindRouterMessage : public IMessage
    {
      // inbound parsing
      FindRouterMessage(const Key_t& from) : IMessage(from)
      {}

      // find by routerid
      FindRouterMessage(uint64_t id, const RouterID& target)
          : IMessage({}), targetKey(target), txid(id)
      {}

      // exploritory
      FindRouterMessage(uint64_t id) : IMessage({}), exploritory(true), txid(id)
      {
        targetKey.Randomize();
      }

      ~FindRouterMessage() override;

      bool
      BEncode(llarp_buffer_t* buf) const override;

      bool
      DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;

      bool
      HandleMessage(
          llarp_dht_context* ctx, std::vector<std::unique_ptr<IMessage>>& replies) const override;

      RouterID targetKey;
      bool iterative = false;
      bool exploritory = false;
      uint64_t txid = 0;
      uint64_t version = 0;
    };

    struct RelayedFindRouterMessage final : public FindRouterMessage
    {
      RelayedFindRouterMessage(const Key_t& from) : FindRouterMessage(from)
      {}

      bool
      HandleMessage(llarp_dht_context* ctx, std::vector<IMessage::Ptr_t>& replies) const override;
    };
  }  // namespace dht
}  // namespace llarp
```


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

Updated on 2022-09-19 at 17:18:35 +0000
