polkadot_node_network_protocol/request_response/
v2.rs1use codec::{Decode, Encode};
20
21use polkadot_node_primitives::ErasureChunk;
22use polkadot_primitives::{
23 CandidateHash, CommittedCandidateReceiptV2 as CommittedCandidateReceipt, Hash, Id as ParaId,
24 PersistedValidationData, UncheckedSignedStatement, ValidatorIndex,
25};
26
27use super::{v1, IsRequest, Protocol};
28use crate::v3::StatementFilter;
29
30#[derive(Debug, Clone, Encode, Decode)]
32pub struct AttestedCandidateRequest {
33 pub candidate_hash: CandidateHash,
35 pub mask: StatementFilter,
43}
44
45#[derive(Debug, Clone, Encode, Decode)]
47pub struct AttestedCandidateResponse {
48 pub candidate_receipt: CommittedCandidateReceipt,
50 pub persisted_validation_data: PersistedValidationData,
52 pub statements: Vec<UncheckedSignedStatement>,
56}
57
58impl IsRequest for AttestedCandidateRequest {
59 type Response = AttestedCandidateResponse;
60 const PROTOCOL: Protocol = Protocol::AttestedCandidateV2;
61}
62
63pub type CollationFetchingResponse = super::v1::CollationFetchingResponse;
65
66#[derive(Debug, Clone, Encode, Decode)]
68pub struct CollationFetchingRequest {
69 pub relay_parent: Hash,
71 pub para_id: ParaId,
73 pub candidate_hash: CandidateHash,
75}
76
77impl IsRequest for CollationFetchingRequest {
78 type Response = CollationFetchingResponse;
80 const PROTOCOL: Protocol = Protocol::CollationFetchingV2;
81}
82
83#[derive(Debug, Copy, Clone, Encode, Decode)]
85pub struct ChunkFetchingRequest {
86 pub candidate_hash: CandidateHash,
88 pub index: ValidatorIndex,
92}
93
94#[derive(Debug, Clone, Encode, Decode)]
96pub enum ChunkFetchingResponse {
97 #[codec(index = 0)]
99 Chunk(ErasureChunk),
100 #[codec(index = 1)]
102 NoSuchChunk,
103}
104
105impl From<Option<ErasureChunk>> for ChunkFetchingResponse {
106 fn from(x: Option<ErasureChunk>) -> Self {
107 match x {
108 Some(c) => ChunkFetchingResponse::Chunk(c),
109 None => ChunkFetchingResponse::NoSuchChunk,
110 }
111 }
112}
113
114impl From<ChunkFetchingResponse> for Option<ErasureChunk> {
115 fn from(x: ChunkFetchingResponse) -> Self {
116 match x {
117 ChunkFetchingResponse::Chunk(c) => Some(c),
118 ChunkFetchingResponse::NoSuchChunk => None,
119 }
120 }
121}
122
123impl From<v1::ChunkFetchingRequest> for ChunkFetchingRequest {
124 fn from(v1::ChunkFetchingRequest { candidate_hash, index }: v1::ChunkFetchingRequest) -> Self {
125 Self { candidate_hash, index }
126 }
127}
128
129impl From<ChunkFetchingRequest> for v1::ChunkFetchingRequest {
130 fn from(ChunkFetchingRequest { candidate_hash, index }: ChunkFetchingRequest) -> Self {
131 Self { candidate_hash, index }
132 }
133}
134
135impl IsRequest for ChunkFetchingRequest {
136 type Response = ChunkFetchingResponse;
137 const PROTOCOL: Protocol = Protocol::ChunkFetchingV2;
138}