#pragma once #include #include #include #include #include #include "address.hpp" #include #include namespace llarp::service { /// tracks and manages consensus of lns names we fetch from the network class LNSLookupTracker { public: using Addr_t = std::variant; private: struct LookupInfo { std::unordered_set m_CurrentValues; std::function)> m_HandleResult; std::size_t m_ResultsGotten = 0; std::size_t m_ResultsNeeded; LookupInfo(std::size_t wantResults, std::function)> resultHandler) : m_HandleResult{std::move(resultHandler)}, m_ResultsNeeded{wantResults} {} bool IsDone() const; void HandleOneResult(std::optional result); }; std::unordered_map m_PendingLookups; public: /// make a function that will handle consensus of an lns request /// name is the name we are requesting /// numPeers is the number of peers we asked /// resultHandler is a function that we are wrapping that will handle the final result std::function)> MakeResultHandler( std::string name, std::size_t numPeers, std::function)> resultHandler); }; } // namespace llarp::service