Helper for sending rate-limited gossip messages.
NetworkService struct provides a way to send notifications to a certain peer through
NetworkService::notification_sender method. This method is quite low level and isn't
expected to be used directly.
An instance of
QueuedSender is specific to a certain combination of
protocol name. It maintains a buffer of messages waiting to be sent out. The user of this API
is able to manipulate that queue, adding or removing obsolete messages.
QueuedSender also returns a opaque
Future whose responsibility it to
drain that queue and actually send the messages. If the substream with the given combination
of peer and protocol is closed, the queue is silently discarded. It is the role of the user
to track which peers we are connected to.
In normal situations, messages sent through a
QueuedSender will arrive in the same
order as they have been sent.
It is possible, in the situation of disconnects and reconnects, that messages arrive in a
different order. See also https://github.com/paritytech/substrate/issues/6756.
However, if multiple instances of
QueuedSender exist for the same peer and protocol, or
if some other code uses the
NetworkService to send notifications to this combination or
peer and protocol, then the notifications will be interleaved in an unpredictable way.
Locked queue of messages to the given peer.
Notifications sender for a specific combination of network service, peer, and protocol.