3#include <xrpl/basics/CountedObject.h>
4#include <xrpl/basics/UnorderedContainers.h>
5#include <xrpl/basics/base_uint.h>
6#include <xrpl/basics/chrono.h>
7#include <xrpl/beast/container/aged_unordered_map.h>
std::chrono::steady_clock::time_point time_point
bool shouldProcess(Stopwatch::time_point now, std::chrono::seconds interval)
bool shouldRelay(Stopwatch::time_point const &now, std::chrono::seconds relayTime)
Determines if this item should be relayed.
std::optional< Stopwatch::time_point > relayed_
void addPeer(PeerShortID peer)
std::optional< Stopwatch::time_point > relayed() const
Return seated relay time point if the message has been relayed.
void setFlags(HashRouterFlags flagsToSet)
std::set< PeerShortID > releasePeerSet()
Return set of peers we've relayed to and reset tracking.
HashRouterFlags getFlags(void) const
std::optional< Stopwatch::time_point > processed_
std::set< PeerShortID > peers_
Routing table for objects identified by hash.
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
virtual ~HashRouter()=default
HashRouterFlags getFlags(uint256 const &key)
HashRouter(Setup const &setup, Stopwatch &clock)
bool addSuppressionPeer(uint256 const &key, PeerShortID peer)
bool setFlags(uint256 const &key, HashRouterFlags flags)
Set the flags on a hash.
std::pair< bool, std::optional< Stopwatch::time_point > > addSuppressionPeerWithStatus(uint256 const &key, PeerShortID peer)
Add a suppression peer and get message's relay status.
std::pair< Entry &, bool > emplace(uint256 const &)
bool shouldProcess(uint256 const &key, PeerShortID peer, HashRouterFlags &flags, std::chrono::seconds txInterval)
beast::aged_unordered_map< uint256, Entry, Stopwatch::clock_type, HardenedHash< strong_hash > > suppressionMap_
void addSuppression(uint256 const &key)
HashRouter & operator=(HashRouter const &)=delete
std::uint32_t PeerShortID
detail::AgedUnorderedContainer< false, true, Key, T, Clock, Hash, KeyEqual, Allocator > aged_unordered_map
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
beast::AbstractClock< std::chrono::steady_clock > Stopwatch
A clock for measuring elapsed time.
constexpr BaseUInt< Bits, Tag > operator&(BaseUInt< Bits, Tag > const &a, BaseUInt< Bits, Tag > const &b)
constexpr HashRouterFlags & operator|=(HashRouterFlags &lhs, HashRouterFlags rhs)
constexpr BaseUInt< Bits, Tag > operator|(BaseUInt< Bits, Tag > const &a, BaseUInt< Bits, Tag > const &b)
constexpr HashRouterFlags & operator&=(HashRouterFlags &lhs, HashRouterFlags rhs)
constexpr bool any(HashRouterFlags flags)
Structure used to customize HashRouter behavior.
seconds holdTime
Expiration time for a hash entry.
seconds relayTime
Amount of time required before a relayed item will be relayed again.
std::chrono::seconds seconds
Setup()=default
Default constructor.