mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-09 13:10:25 +00:00
baf8019fe5
This commit refactors functionality from the Router class into separate, dedicated classes. There are a few behavior changes that came as a result of discussion on what the correct behavior should be. In addition, many things Router was previously doing can now be provided callback functions to alert the calling point when the asynchronous action completes, successfully or otherwise.
64 lines
1.3 KiB
C++
64 lines
1.3 KiB
C++
#ifndef LLARP_I_RC_LOOKUP_HANDLER_HPP
|
|
#define LLARP_I_RC_LOOKUP_HANDLER_HPP
|
|
|
|
#include <util/types.hpp>
|
|
#include <router_id.hpp>
|
|
|
|
#include <memory>
|
|
#include <set>
|
|
#include <vector>
|
|
|
|
namespace llarp
|
|
{
|
|
struct RouterContact;
|
|
|
|
enum class RCRequestResult
|
|
{
|
|
Success,
|
|
InvalidRouter,
|
|
RouterNotFound,
|
|
BadRC
|
|
};
|
|
|
|
using RCRequestCallback = std::function< void(
|
|
const RouterID &, const RouterContact *const, const RCRequestResult) >;
|
|
|
|
struct I_RCLookupHandler
|
|
{
|
|
virtual ~I_RCLookupHandler() = default;
|
|
|
|
virtual void
|
|
AddValidRouter(const RouterID &router) = 0;
|
|
|
|
virtual void
|
|
RemoveValidRouter(const RouterID &router) = 0;
|
|
|
|
virtual void
|
|
SetRouterWhitelist(const std::vector< RouterID > &routers) = 0;
|
|
|
|
virtual void
|
|
GetRC(const RouterID &router, RCRequestCallback callback) = 0;
|
|
|
|
virtual bool
|
|
RemoteIsAllowed(const RouterID &remote) const = 0;
|
|
|
|
virtual bool
|
|
CheckRC(const RouterContact &rc) const = 0;
|
|
|
|
virtual bool
|
|
GetRandomWhitelistRouter(RouterID &router) const = 0;
|
|
|
|
virtual bool
|
|
CheckRenegotiateValid(RouterContact newrc, RouterContact oldrc) = 0;
|
|
|
|
virtual void
|
|
PeriodicUpdate(llarp_time_t now) = 0;
|
|
|
|
virtual void
|
|
ExploreNetwork() = 0;
|
|
};
|
|
|
|
} // namespace llarp
|
|
|
|
#endif // LLARP_I_RC_LOOKUP_HANDLER_HPP
|