20 #ifndef RIPPLE_OVERLAY_SQUELCH_H_INCLUDED
21 #define RIPPLE_OVERLAY_SQUELCH_H_INCLUDED
23 #include <ripple/basics/random.h>
24 #include <ripple/overlay/SquelchCommon.h>
25 #include <ripple/protocol/PublicKey.h>
35 template <
typename clock_type>
70 template <
typename clock_type>
75 uint64_t squelchDuration)
79 squelched_[validator] = [squelchDuration]() {
81 return clock_type::now() +
85 : getSquelchDuration());
89 squelched_.erase(validator);
92 template <
typename clock_type>
96 auto now = clock_type::now();
98 auto const& it = squelched_.find(validator);
99 if (it == squelched_.end())
101 else if (it->second > now)
104 squelched_.erase(it);
109 template <
typename clock_type>
122 #endif // RIPPLED_SQUELCH_H
hash_map< PublicKey, time_point > squelched_
Maintains the list of squelched relaying to downstream peers.
static constexpr seconds MAX_UNSQUELCH_EXPIRE
static seconds getSquelchDuration()
Get random squelch duration between MIN_UNSQUELCH_EXPIRE and MAX_UNSQUELCH_EXPIRE.
static constexpr seconds MIN_UNSQUELCH_EXPIRE
typename ripple::UptimeClock ::time_point time_point
std::enable_if_t< std::is_integral< Integral >::value &&detail::is_engine< Engine >::value, Integral > rand_int(Engine &engine, Integral min, Integral max)
Return a uniformly distributed random integer.
bool isSquelched(PublicKey const &validator)
Are the messages to this validator squelched.
virtual ~Squelch()=default
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Maintains squelching of relaying messages from validators.
void squelch(PublicKey const &validator, bool squelch, uint64_t squelchDuration)
Squelch/Unsquelch relaying for the validator.