---
title: llarp/service/lns_tracker.hpp

---

# llarp/service/lns_tracker.hpp



## Namespaces

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

## Classes

|                | Name           |
| -------------- | -------------- |
| class | **[llarp::service::LNSLookupTracker](Classes/classllarp_1_1service_1_1LNSLookupTracker.md)** <br>tracks and manages consensus of lns names we fetch from the network  |




## Source code

```cpp
#pragma once

#include <functional>
#include <optional>
#include <unordered_map>
#include <unordered_set>
#include <string>

#include "address.hpp"
#include <llarp/router_id.hpp>
#include <oxenc/variant.h>

namespace llarp::service
{
  class LNSLookupTracker
  {
   public:
    using Addr_t = std::variant<Address, RouterID>;

   private:
    struct LookupInfo
    {
      std::unordered_set<Addr_t> m_CurrentValues;
      std::function<void(std::optional<Addr_t>)> m_HandleResult;
      std::size_t m_ResultsGotten = 0;
      std::size_t m_ResultsNeeded;

      LookupInfo(std::size_t wantResults, std::function<void(std::optional<Addr_t>)> resultHandler)
          : m_HandleResult{std::move(resultHandler)}, m_ResultsNeeded{wantResults}
      {}

      bool
      IsDone() const;

      void
      HandleOneResult(std::optional<Addr_t> result);
    };

    std::unordered_map<std::string, LookupInfo> m_PendingLookups;

   public:
    std::function<void(std::optional<Addr_t>)>
    MakeResultHandler(
        std::string name,
        std::size_t numPeers,
        std::function<void(std::optional<Addr_t>)> resultHandler);
  };
}  // namespace llarp::service
```


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

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