Skip to main content

Crate request_response

Crate request_response 

Source
Expand description

This crate contains a general request-response protocol. It is used to send requests to a set of recipients and wait for responses.

Modulesยง

data_source
The data source trait. Is what we use to derive the response data for a request This file contains the DataSource trait. This trait allows the [RequestResponseProtocol] to calculate/derive a response for a specific request. In the confirmation layer the implementer would be something like a [FeeMerkleTree] for fee catchup
message
The message type. Is the base type for all messages in the request-response protocol
network
The network traits. Is what we use to send and receive messages over the network as the protocol This file contains the Sender and Receiver traits. These traits are used by the [RequestResponseProtocol] to send and receive messages from a network or other source.
recipient_source
The recipient source trait. Is what we use to get the recipients that a specific message should expect responses from
request
The request trait. Is what we use to define a request and a corresponding response type This file contains the Request and [Response] traits. Any upstream that wants to use the [RequestResponseProtocol] needs to implement these traits for their specific types.
util ๐Ÿ”’
Utility types and functions

Structsยง

RequestResponse
A protocol that allows for request-response communication. Is cheaply cloneable, so there is no need to wrap it in an Arc
RequestResponseConfig
The underlying configuration for the request-response protocol
RequestResponseInner
The inner implementation for the request-response protocol
ResponseReceiver ๐Ÿ”’
Receives candidate responses for one RequestResponseInner::request call. Deregisters the waiter when dropped, so map entries are cleaned up on success, timeout, and cancellation alike
Waiter ๐Ÿ”’
A waiter registered by one RequestResponseInner::request call, to which incoming responses for its request hash are delivered

Enumsยง

RequestError
The errors that can occur when making a request for data

Constantsยง

RESPONSE_BUFFER_SIZE ๐Ÿ”’
The number of serialized responses each waiter buffers before drops occur. Only one valid response is needed and batched senders keep re-requesting, so extra responses are free to drop. Kept small because bodies (leaves, merkle trees, VID shares) can be large and every in-flight request pins its own buffer

Traitsยง

Serializable
A trait for serializing and deserializing a type to and from a byte array. Request types and [Response] types will need to implement this trait

Type Aliasesยง

ActiveRequestsMap ๐Ÿ”’
The map of active outgoing requests: request hash โ†’ the waiters registered by concurrent RequestResponseInner::request calls for the same data. Guarded by a synchronous lock so waiters can deregister themselves in Drop; it is never held across an await
IncomingRequests
A type alias for the list of tasks that are responding to requests
RequestHash
A type alias for the hash of a request