polkadot_node_network_protocol/request_response/v3.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16
17//! Requests and responses as sent over the wire for the individual protocols.
18
19use super::{IsRequest, Protocol};
20use codec::{Decode, Encode};
21use polkadot_node_primitives::PoV;
22use polkadot_primitives::{CandidateReceiptV2 as CandidateReceipt, Hash, HeadData, Id as ParaId};
23
24/// Request the advertised collation at that scheduling parent
25#[derive(Debug, Clone, Encode, Decode)]
26pub struct CollationFetchingRequest {
27 /// Relay parent collation is built on top of.
28 pub scheduling_parent: Hash,
29 /// The `ParaId` of the collation.
30 pub para_id: ParaId,
31 /// Output head hash of the candidate
32 pub output_head_data_hash: Hash,
33}
34
35impl IsRequest for CollationFetchingRequest {
36 type Response = CollationFetchingResponse;
37 const PROTOCOL: Protocol = Protocol::CollationFetchingV3;
38}
39
40/// Response as sent by collator supporting low latency
41#[derive(Debug, Clone, Encode, Decode)]
42pub enum CollationFetchingResponse {
43 /// Deliver requested collation along with parent head data.
44 #[codec(index = 0)]
45 Collation {
46 /// The receipt of the candidate.
47 receipt: CandidateReceipt,
48 /// Candidate's proof of validity
49 pov: PoV,
50 /// The head data of the candidate's parent.
51 /// This is needed for elastic scaling to work.
52 parent_head_data: HeadData,
53 },
54}