Module libp2p_request_response::throttled
source · [−]Expand description
Limit the number of requests peers can send to each other.
Each peer is assigned a budget for sending and a budget for receiving requests. Initially a peer assumes it has a send budget of 1. When its budget has been used up its remote peer will send a credit message which informs it how many more requests it can send before it needs to wait for the next credit message. Credit messages which error or time out are retried until they have reached the peer which is assumed once a corresponding ack or a new request has been received from the peer.
The Throttled
behaviour wraps an existing RequestResponse
behaviour
and uses a codec implementation that sends ordinary requests and responses
as well as a special credit message to which an ack message is expected
as a response. It does so by putting a small CBOR encoded header in front
of each message the inner codec produces.
Structs
A wrapper around RequestResponse
which adds request limits per peer.
Enums
A Wrapper around RequestResponseEvent
.