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.
lokinet/llarp/router/rc_gossiper.hpp

54 lines
985 B
C++

#pragma once
5 years ago
#include <llarp/util/decaying_hashset.hpp>
#include "outbound_message_handler.hpp"
5 years ago
namespace llarp
{
/// The maximum number of peers we will flood a gossiped RC to when propagating an RC
constexpr size_t MaxGossipPeers = 20;
struct LinkManager;
struct RouterContact;
struct RCGossiper
5 years ago
{
using Time_t = Duration_t;
5 years ago
RCGossiper();
~RCGossiper() = default;
5 years ago
bool
GossipRC(const RouterContact& rc);
5 years ago
void
Decay(Time_t now);
bool
ShouldGossipOurRC(Time_t now) const;
bool
IsOurRC(const RouterContact& rc) const;
5 years ago
void
Init(LinkManager*, const RouterID&, Router*);
5 years ago
void
Forget(const RouterID& router);
TimePoint_t
NextGossipAt() const;
std::optional<TimePoint_t>
LastGossipAt() const;
5 years ago
private:
RouterID rid;
Time_t last_rc_gossip = 0s;
LinkManager* link_manager = nullptr;
util::DecayingHashSet<RouterID> filter;
Router* router;
5 years ago
};
} // namespace llarp