Struct network::protocols::rpc::InboundRpcRequest
source · pub struct InboundRpcRequest {
pub protocol_id: ProtocolId,
pub data: Bytes,
pub res_tx: Sender<Result<Bytes, RpcError>>,
}
Expand description
A wrapper struct for an inbound rpc request and its associated context.
Fields§
§protocol_id: ProtocolId
The ProtocolId
for which of our upstream application modules should
handle (i.e., deserialize and then respond to) this inbound rpc request.
For example, if protocol_id == ProtocolId::ConsensusRpc
, then this
inbound rpc request will be dispatched to consensus for handling.
data: Bytes
The serialized request data received from the sender. At this layer in the stack, the request data is just an opaque blob and will only be fully deserialized later in the handling application module.
res_tx: Sender<Result<Bytes, RpcError>>
Channel over which the rpc response is sent from the upper application layer to the network rpc layer.
The rpc actor holds onto the receiving end of this channel, awaiting the
response from the upper layer. If there is an error in, e.g.,
deserializing the request, the upper layer should send an RpcError
down the channel to signify that there was an error while handling this
rpc request. Currently, we just log these errors and drop the request.
The upper client layer should be prepared for res_tx
to be disconnected
when trying to send their response, as the rpc call might have timed out
while handling the request.