adds method to SquelchHandler to squelch all peers

This commit is contained in:
Vito
2025-05-28 16:21:47 +02:00
parent 6bbd836adc
commit 54678dc2a4
3 changed files with 23 additions and 1 deletions

View File

@@ -75,7 +75,7 @@ public:
virtual ~SquelchHandler()
{
}
/** Squelch handler
/** Squelch handler for a single peer
* @param validator Public key of the source validator
* @param id Peer's id to squelch
* @param duration Squelch duration in seconds
@@ -83,6 +83,15 @@ public:
virtual void
squelch(PublicKey const& validator, Peer::id_t id, std::uint32_t duration)
const = 0;
/** Squelch for all peers, the method must call slots.squelchValidator
* to register that a (validator,peer) was squelched
* @param validator Public key of the source validator
* @param duration Squelch duration in seconds
*/
virtual void
squelchAll(PublicKey const& validator, std::uint32_t duration) = 0;
/** Unsquelch handler
* @param validator Public key of the source validator
* @param id Peer's id to unsquelch

View File

@@ -1410,6 +1410,15 @@ OverlayImpl::squelch(
}
}
void
OverlayImpl::squelchAll(PublicKey const& validator, uint32_t squelchDuration)
{
for_each([&](std::shared_ptr<PeerImp>&& p) {
slots_.squelchValidator(validator, p->id());
p->send(makeSquelchMessage(validator, true, squelchDuration));
});
}
void
OverlayImpl::updateSlotAndSquelch(
uint256 const& key,

View File

@@ -451,6 +451,10 @@ private:
Peer::id_t const id,
std::uint32_t squelchDuration) const override;
void
squelchAll(PublicKey const& validator, std::uint32_t squelchDuration)
override;
void
unsquelch(PublicKey const& validator, Peer::id_t id) const override;