async fn batch_misbehavior_updates(
misbehavior_rx: Receiver<MisbehaviorReport>,
address_book_updater: AddressBookChangeSender,
flush_interval: Duration,
)Expand description
Batches peer misbehaviour reports from misbehavior_rx, and sends them to the address
book every flush_interval.
Batching stops peers from keeping the address book mutex locked by repeatedly sending invalid blocks or transactions.
Senders use try_send(), so this task keeps receiving while a flush is waiting for the
address book updater. Otherwise the channel could fill up during the flush, and new
reports would be dropped.
§Security
A report that bans a peer is sent right away, not at the next flush. A peer that serves a
forged body for a block that only it advertised would otherwise keep getting the requests for
that block until its ban landed, and the requester gives up after a few retries
(GHSA-g9rc-89v4-hhvf). Each peer address gets at most one early ban per flush_interval, and
banned peers are disconnected, so peers still can’t keep the address book busy.