2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
|
|
|
#include <llarp/router_contact.hpp>
|
2022-05-04 14:37:35 +00:00
|
|
|
#include <llarp/util/time.hpp>
|
|
|
|
#include <optional>
|
2020-01-30 17:23:16 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2021-08-31 14:23:24 +00:00
|
|
|
/// The maximum number of peers we will flood a gossiped RC to when propagating an RC
|
|
|
|
constexpr size_t MaxGossipPeers = 20;
|
|
|
|
|
2020-01-30 17:23:16 +00:00
|
|
|
struct I_RCGossiper
|
|
|
|
{
|
|
|
|
virtual ~I_RCGossiper() = default;
|
|
|
|
/// try goissping RC
|
|
|
|
/// return false if we hit a cooldown for this rc
|
|
|
|
/// return true if we gossiped this rc to at least 1 peer
|
|
|
|
virtual bool
|
2020-04-07 18:38:56 +00:00
|
|
|
GossipRC(const RouterContact& rc) = 0;
|
2020-01-30 17:23:16 +00:00
|
|
|
|
2022-05-04 14:37:35 +00:00
|
|
|
using Time_t = Duration_t;
|
2020-02-25 17:05:13 +00:00
|
|
|
|
2020-01-30 17:23:16 +00:00
|
|
|
virtual void
|
2020-01-30 22:10:56 +00:00
|
|
|
Decay(Time_t now) = 0;
|
|
|
|
|
|
|
|
/// return true if we should gossip our RC now
|
|
|
|
virtual bool
|
|
|
|
ShouldGossipOurRC(Time_t now) const = 0;
|
|
|
|
|
|
|
|
/// return true if that rc is owned by us
|
|
|
|
virtual bool
|
2020-04-07 18:38:56 +00:00
|
|
|
IsOurRC(const RouterContact& rc) const = 0;
|
2022-05-03 20:05:22 +00:00
|
|
|
|
|
|
|
/// forget the replay filter entry given pubkey
|
|
|
|
virtual void
|
|
|
|
Forget(const RouterID& router) = 0;
|
2022-05-04 14:37:35 +00:00
|
|
|
|
|
|
|
/// returns the time point when we will send our next gossip at
|
|
|
|
virtual TimePoint_t
|
|
|
|
NextGossipAt() const = 0;
|
|
|
|
|
|
|
|
/// returns the time point when we sent our last gossip at or nullopt if we never did
|
|
|
|
virtual std::optional<TimePoint_t>
|
|
|
|
LastGossipAt() const = 0;
|
2020-01-30 17:23:16 +00:00
|
|
|
};
|
|
|
|
} // namespace llarp
|