20#ifndef RIPPLE_APP_MISC_HASHROUTER_H_INCLUDED
21#define RIPPLE_APP_MISC_HASHROUTER_H_INCLUDED
23#include <xrpl/basics/CountedObject.h>
24#include <xrpl/basics/UnorderedContainers.h>
25#include <xrpl/basics/base_uint.h>
26#include <xrpl/basics/chrono.h>
27#include <xrpl/beast/container/aged_unordered_map.h>
typename Clock::time_point time_point
std::chrono::steady_clock clock_type
Associative container where each element is also indexed by time.
Tracks the number of instances of an object.
An entry in the routing table.
std::optional< Stopwatch::time_point > processed_
std::set< PeerShortID > peers_
std::optional< Stopwatch::time_point > relayed() const
Return seated relay time point if the message has been relayed.
std::optional< Stopwatch::time_point > relayed_
void setFlags(HashRouterFlags flagsToSet)
HashRouterFlags getFlags(void) const
void addPeer(PeerShortID peer)
std::set< PeerShortID > releasePeerSet()
Return set of peers we've relayed to and reset tracking.
bool shouldRelay(Stopwatch::time_point const &now, std::chrono::seconds relayTime)
Determines if this item should be relayed.
bool shouldProcess(Stopwatch::time_point now, std::chrono::seconds interval)
Routing table for objects identified by hash.
beast::aged_unordered_map< uint256, Entry, Stopwatch::clock_type, hardened_hash< strong_hash > > suppressionMap_
HashRouterFlags getFlags(uint256 const &key)
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
bool shouldProcess(uint256 const &key, PeerShortID peer, HashRouterFlags &flags, std::chrono::seconds tx_interval)
virtual ~HashRouter()=default
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.
HashRouter & operator=(HashRouter const &)=delete
HashRouter(Setup const &setup, Stopwatch &clock)
std::pair< Entry &, bool > emplace(uint256 const &)
void addSuppression(uint256 const &key)
Seed functor once per construction.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
ApplyFlags operator|=(ApplyFlags &lhs, ApplyFlags const &rhs)
constexpr base_uint< Bits, Tag > operator|(base_uint< Bits, Tag > const &a, base_uint< Bits, Tag > const &b)
ApplyFlags operator&=(ApplyFlags &lhs, ApplyFlags const &rhs)
constexpr base_uint< Bits, Tag > operator&(base_uint< Bits, Tag > const &a, base_uint< Bits, Tag > const &b)
HashRouter::Setup setup_HashRouter(Config const &config)
Structure used to customize HashRouter behavior.
Setup()=default
Default constructor.
seconds holdTime
Expiration time for a hash entry.
seconds relayTime
Amount of time required before a relayed item will be relayed again.