1#ifndef XRPL_OVERLAY_SQUELCH_H_INCLUDED
2#define XRPL_OVERLAY_SQUELCH_H_INCLUDED
4#include <xrpld/overlay/ReduceRelayCommon.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/protocol/PublicKey.h>
15namespace reduce_relay {
18template <
typename clock_type>
59template <
typename clock_type>
68 squelched_[validator] = clock_type::now() + squelchDuration;
72 JLOG(journal_.error()) <<
"squelch: invalid squelch duration "
73 << squelchDuration.
count();
76 removeSquelch(validator);
81template <
typename clock_type>
85 squelched_.erase(validator);
88template <
typename clock_type>
92 auto now = clock_type::now();
94 auto const& it = squelched_.find(validator);
95 if (it == squelched_.end())
97 else if (it->second > now)
101 squelched_.erase(it);
A generic endpoint for log messages.
Maintains squelching of relaying messages from validators.
typename clock_type::time_point time_point
beast::Journal const journal_
hash_map< PublicKey, time_point > squelched_
Maintains the list of squelched relaying to downstream peers.
virtual ~Squelch()=default
bool addSquelch(PublicKey const &validator, std::chrono::seconds const &squelchDuration)
Squelch validation/proposal relaying for the validator.
bool expireSquelch(PublicKey const &validator)
Remove expired squelch.
void removeSquelch(PublicKey const &validator)
Remove the squelch.
Squelch(beast::Journal journal)
static constexpr auto MIN_UNSQUELCH_EXPIRE
static constexpr auto MAX_UNSQUELCH_EXPIRE_PEERS
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.