Expand description
This module defines PeerRequest
and PeerResponse
. Cuprate’s P2P crates works by translating network messages into an internal
request/response enums, this is easy for levin “requests” and “responses” (admin messages) but takes a bit more work with “notifications”
(protocol messages).
Some notifications are easy to translate, like GetObjectsRequest
is obviously a request but others like NewFluffyBlock
are a
bit tricker. To translate a NewFluffyBlock
into a request/ response we will have to look to see if we asked for FluffyMissingTransactionsRequest
,
if we have, we interpret NewFluffyBlock
as a response, if not, it’s a request that doesn’t require a response.
Here is every P2P request/response.
*note admin messages are already request/response so “Handshake” is actually made of a HandshakeRequest
& HandshakeResponse
Admin:
Handshake,
TimedSync,
Ping,
SupportFlags
Protocol:
Request: GetObjectsRequest, Response: GetObjectsResponse,
Request: ChainRequest, Response: ChainResponse,
Request: FluffyMissingTransactionsRequest, Response: NewFluffyBlock, <- these 2 could be requests or responses
Request: GetTxPoolCompliment, Response: NewTransactions, <-
Request: NewBlock, Response: None,
Request: NewFluffyBlock, Response: None,
Request: NewTransactions, Response: None
Enums§
- An enum representing a request/ response combination, so a handshake request and response would have the same
MessageID
. This allows associating the correct response to a request.