mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
997 B
C++
58 lines
997 B
C++
#pragma once
|
|
|
|
#include <llarp/router_id.hpp>
|
|
#include <llarp/util/decaying_hashset.hpp>
|
|
|
|
#include <optional>
|
|
|
|
namespace llarp
|
|
{
|
|
struct Router;
|
|
|
|
/// The maximum number of peers we will flood a gossiped RC to when propagating an RC
|
|
constexpr size_t MaxGossipPeers = 20;
|
|
struct LinkManager;
|
|
struct LocalRC;
|
|
|
|
struct RCGossiper
|
|
{
|
|
using Time_t = Duration_t;
|
|
|
|
RCGossiper();
|
|
|
|
~RCGossiper() = default;
|
|
|
|
bool
|
|
GossipRC(const LocalRC& rc);
|
|
|
|
void
|
|
Decay(Time_t now);
|
|
|
|
bool
|
|
ShouldGossipOurRC(Time_t now) const;
|
|
|
|
bool
|
|
IsOurRC(const LocalRC& rc) const;
|
|
|
|
void
|
|
Init(LinkManager*, const RouterID&, Router*);
|
|
|
|
void
|
|
Forget(const RouterID& router);
|
|
|
|
TimePoint_t
|
|
NextGossipAt() const;
|
|
|
|
std::optional<TimePoint_t>
|
|
LastGossipAt() const;
|
|
|
|
private:
|
|
RouterID rid;
|
|
Time_t last_rc_gossip = 0s;
|
|
LinkManager* link_manager = nullptr;
|
|
util::DecayingHashSet<RouterID> filter;
|
|
|
|
Router* router;
|
|
};
|
|
} // namespace llarp
|