20 #ifndef RIPPLE_APP_MISC_HASHROUTER_H_INCLUDED
21 #define RIPPLE_APP_MISC_HASHROUTER_H_INCLUDED
23 #include <ripple/basics/CountedObject.h>
24 #include <ripple/basics/UnorderedContainers.h>
25 #include <ripple/basics/base_uint.h>
26 #include <ripple/basics/chrono.h>
27 #include <ripple/beast/container/aged_unordered_map.h>
34 #define SF_BAD 0x02 // Temporarily bad
36 #define SF_TRUSTED 0x10 // comes from trusted source
40 #define SF_PRIVATE1 0x0100
41 #define SF_PRIVATE2 0x0200
42 #define SF_PRIVATE3 0x0400
43 #define SF_PRIVATE4 0x0800
44 #define SF_PRIVATE5 0x1000
45 #define SF_PRIVATE6 0x2000
bool shouldRelay(Stopwatch::time_point const &now, std::chrono::seconds holdTime)
Determines if this item should be relayed.
std::pair< bool, std::optional< Stopwatch::time_point > > addSuppressionPeerWithStatus(uint256 const &key, PeerShortID peer)
Add a suppression peer and get message's relay status.
void setFlags(int flagsToSet)
Tracks the number of instances of an object.
bool addSuppressionPeer(uint256 const &key, PeerShortID peer)
std::pair< Entry &, bool > emplace(uint256 const &)
int getFlags(uint256 const &key)
std::set< PeerShortID > releasePeerSet()
Return set of peers we've relayed to and reset tracking.
An entry in the routing table.
bool shouldProcess(uint256 const &key, PeerShortID peer, int &flags, std::chrono::seconds tx_interval)
std::optional< Stopwatch::time_point > relayed_
std::chrono::steady_clock clock_type
std::optional< Stopwatch::time_point > processed_
Routing table for objects identified by hash.
virtual ~HashRouter()=default
std::optional< Stopwatch::time_point > relayed() const
Return seated relay time point if the message has been relayed.
beast::aged_unordered_map< uint256, Entry, Stopwatch::clock_type, hardened_hash< strong_hash > > suppressionMap_
const std::chrono::seconds holdTime_
static std::chrono::seconds getDefaultHoldTime()
void addSuppression(uint256 const &key)
Seed functor once per construction.
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
HashRouter & operator=(HashRouter const &)=delete
HashRouter(Stopwatch &clock, std::chrono::seconds entryHoldTimeInSeconds)
void addPeer(PeerShortID peer)
Associative container where each element is also indexed by time.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool shouldProcess(Stopwatch::time_point now, std::chrono::seconds interval)
std::uint32_t PeerShortID
typename std::chrono::steady_clock ::time_point time_point
bool setFlags(uint256 const &key, int flags)
Set the flags on a hash.
std::set< PeerShortID > peers_