lokinet/llarp/router/i_rc_lookup_handler.hpp
Jason Rhinelander c5e787b8cb Oxend error ping + unfunded tracking
Currently (from a recent PR) we aren't pinging oxend if not active, but
that behaviour ended up being quite wrong because lokinet needs to ping
even when decommissioned or deregistered (when decommissioned we need
the ping to get commissioned again, and if not registered we need the
ping to get past the "lokinet isn't pinging" nag screen to prepare a
registration).

This considerably revises the pinging behaviour:

- We ping oxend *unless* there is a specific error with our connections
  (i.e. we *should* be establishing peer connections but don't have any)
- If we do have such an error, we send a new oxend "error" ping to
  report the error to oxend and get oxend to hold off on sending uptime
  proofs.

Along the way this also changes how we handle the current node state:
instead of just tracking deregistered/decommissioned, we now track three
states:

- LooksRegistered -- which means the SN is known to the network (but not
  necessarily active or fully staked)
- LooksFunded -- which means it is known *and* is fully funded, but not
  necessarily active
- LooksDecommissioned -- which means it is known, funded, and not
  currently active (which implies decommissioned).

The funded (or more precisely, unfunded) state is now tracked in
rc_lookup_handler in a "greenlist" -- i.e. new SNs that are so new (i.e.
"green") that they aren't even fully staked or active yet.
2022-10-14 20:55:21 -03:00

82 lines
1.7 KiB
C++

#pragma once
#include <llarp/util/types.hpp>
#include <llarp/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>& whitelist,
const std::vector<RouterID>& greylist,
const std::vector<RouterID>& greenlist) = 0;
virtual void
GetRC(const RouterID& router, RCRequestCallback callback, bool forceLookup = false) = 0;
virtual bool
PathIsAllowed(const RouterID& remote) const = 0;
virtual bool
SessionIsAllowed(const RouterID& remote) const = 0;
virtual bool
IsGreylisted(const RouterID& remote) const = 0;
virtual bool
IsGreenlisted(const RouterID& remote) const = 0;
virtual bool
IsRegistered(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;
virtual size_t
NumberOfStrictConnectRouters() const = 0;
virtual bool
HaveReceivedWhitelist() const = 0;
};
} // namespace llarp