Closed
Description
This is related to the Message
struct in polkadot-sdk/substrate/client/network/src/protocol/message.rs
:
/// A network message.
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
pub enum Message<Header, Hash, Number, Extrinsic> {
/// Status packet.
Status(Status<Hash, Number>),
/// Block request.
BlockRequest(BlockRequest<Hash, Number>),
/// Block response.
BlockResponse(BlockResponse<Header, Hash, Extrinsic>),
/// Block announce.
BlockAnnounce(BlockAnnounce<Header>),
/// Consensus protocol message.
// NOTE: index is incremented by 1 due to transaction-related
// message that was removed
#[codec(index = 6)]
Consensus(ConsensusMessage),
/// Remote method call request.
RemoteCallRequest(RemoteCallRequest<Hash>),
/// Remote method call response.
RemoteCallResponse(RemoteCallResponse),
/// Remote storage read request.
RemoteReadRequest(RemoteReadRequest<Hash>),
/// Remote storage read response.
RemoteReadResponse(RemoteReadResponse),
/// Remote header request.
RemoteHeaderRequest(RemoteHeaderRequest<Number>),
/// Remote header response.
RemoteHeaderResponse(RemoteHeaderResponse<Header>),
/// Remote changes request.
RemoteChangesRequest(RemoteChangesRequest<Hash>),
/// Remote changes response.
RemoteChangesResponse(RemoteChangesResponse<Number, Hash>),
/// Remote child storage read request.
RemoteReadChildRequest(RemoteReadChildRequest<Hash>),
/// Batch of consensus protocol messages.
// NOTE: index is incremented by 2 due to finality proof related
// messages that were removed.
#[codec(index = 17)]
ConsensusBatch(Vec<ConsensusMessage>),
}
This encodes to:
fn encode_to<__CodecOutputEdqy: ::codec::Output + ?::core::marker::Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
) {
match *self {
Message::Status(ref aa) => {
__codec_dest_edqy.push_byte(0usize as ::core::primitive::u8);
::codec::Encode::encode_to(aa, __codec_dest_edqy);
}
Message::BlockRequest(ref aa) => {
__codec_dest_edqy.push_byte(1usize as ::core::primitive::u8);
::codec::Encode::encode_to(aa, __codec_dest_edqy);
}
Message::BlockResponse(ref aa) => {
__codec_dest_edqy.push_byte(2usize as ::core::primitive::u8);
::codec::Encode::encode_to(aa, __codec_dest_edqy);
}
Message::BlockAnnounce(ref aa) => {
__codec_dest_edqy.push_byte(3usize as ::core::primitive::u8);
::codec::Encode::encode_to(aa, __codec_dest_edqy);
}
Message::Consensus(ref aa) => {
__codec_dest_edqy.push_byte(6u8 as ::core::primitive::u8);
::codec::Encode::encode_to(aa, __codec_dest_edqy);
}
Message::RemoteCallRequest(ref aa) => {
__codec_dest_edqy.push_byte(5usize as ::core::primitive::u8);
::codec::Encode::encode_to(aa, __codec_dest_edqy);
}
Message::RemoteCallResponse(ref aa) => {
__codec_dest_edqy.push_byte(6usize as ::core::primitive::u8);
::codec::Encode::encode_to(aa, __codec_dest_edqy);
}
Message::RemoteReadRequest(ref aa) => {
__codec_dest_edqy.push_byte(7usize as ::core::primitive::u8);
::codec::Encode::encode_to(aa, __codec_dest_edqy);
}
...
}
}
}
Index 6 is used both for Consensus
and for RemoteCallResponse