mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
Pass relay_parent hash to produce_candidate (#300)
* Pass `relay_parent` hash to `produce_candidate` * Fixes compilation
This commit is contained in:
committed by
Robert Habermeier
parent
67ee212171
commit
23432bb043
@@ -100,9 +100,11 @@ impl<R: fmt::Display> fmt::Display for Error<R> {
|
|||||||
pub trait ParachainContext: Clone {
|
pub trait ParachainContext: Clone {
|
||||||
type ProduceCandidate: IntoFuture<Item=(BlockData, HeadData, Extrinsic), Error=InvalidHead>;
|
type ProduceCandidate: IntoFuture<Item=(BlockData, HeadData, Extrinsic), Error=InvalidHead>;
|
||||||
|
|
||||||
/// Produce a candidate, given the latest ingress queue information and the last parachain head.
|
/// Produce a candidate, given the relay parent hash, the latest ingress queue information
|
||||||
|
/// and the last parachain head.
|
||||||
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
|
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
|
||||||
&self,
|
&self,
|
||||||
|
relay_parent: Hash,
|
||||||
last_head: HeadData,
|
last_head: HeadData,
|
||||||
ingress: I,
|
ingress: I,
|
||||||
) -> Self::ProduceCandidate;
|
) -> Self::ProduceCandidate;
|
||||||
@@ -124,6 +126,7 @@ pub trait RelayChainContext {
|
|||||||
|
|
||||||
/// Produce a candidate for the parachain, with given contexts, parent head, and signing key.
|
/// Produce a candidate for the parachain, with given contexts, parent head, and signing key.
|
||||||
pub fn collate<'a, R, P>(
|
pub fn collate<'a, R, P>(
|
||||||
|
relay_parent: Hash,
|
||||||
local_id: ParaId,
|
local_id: ParaId,
|
||||||
last_head: HeadData,
|
last_head: HeadData,
|
||||||
relay_context: R,
|
relay_context: R,
|
||||||
@@ -142,6 +145,7 @@ pub fn collate<'a, R, P>(
|
|||||||
ingress
|
ingress
|
||||||
.and_then(move |ingress| {
|
.and_then(move |ingress| {
|
||||||
para_context.produce_candidate(
|
para_context.produce_candidate(
|
||||||
|
relay_parent,
|
||||||
last_head,
|
last_head,
|
||||||
ingress.0.iter().flat_map(|&(id, ref msgs)| msgs.iter().cloned().map(move |msg| (id, msg)))
|
ingress.0.iter().flat_map(|&(id, ref msgs)| msgs.iter().cloned().map(move |msg| (id, msg)))
|
||||||
)
|
)
|
||||||
@@ -327,6 +331,7 @@ impl<P, E> Worker for CollationNode<P, E> where
|
|||||||
};
|
};
|
||||||
|
|
||||||
let collation_work = collate(
|
let collation_work = collate(
|
||||||
|
relay_parent,
|
||||||
para_id,
|
para_id,
|
||||||
HeadData(last_head),
|
HeadData(last_head),
|
||||||
context,
|
context,
|
||||||
@@ -427,6 +432,7 @@ mod tests {
|
|||||||
|
|
||||||
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
|
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
|
||||||
&self,
|
&self,
|
||||||
|
_relay_parent: Hash,
|
||||||
_last_head: HeadData,
|
_last_head: HeadData,
|
||||||
ingress: I,
|
ingress: I,
|
||||||
) -> Result<(BlockData, HeadData, Extrinsic), InvalidHead> {
|
) -> Result<(BlockData, HeadData, Extrinsic), InvalidHead> {
|
||||||
@@ -476,6 +482,7 @@ mod tests {
|
|||||||
]));
|
]));
|
||||||
|
|
||||||
let collation = collate(
|
let collation = collate(
|
||||||
|
Default::default(),
|
||||||
id,
|
id,
|
||||||
HeadData(vec![5]),
|
HeadData(vec![5]),
|
||||||
context.clone(),
|
context.clone(),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use std::sync::Arc;
|
|||||||
use adder::{HeadData as AdderHead, BlockData as AdderBody};
|
use adder::{HeadData as AdderHead, BlockData as AdderBody};
|
||||||
use substrate_primitives::Pair;
|
use substrate_primitives::Pair;
|
||||||
use parachain::codec::{Encode, Decode};
|
use parachain::codec::{Encode, Decode};
|
||||||
use primitives::parachain::{HeadData, BlockData, Id as ParaId, Message, Extrinsic};
|
use primitives::{Hash, parachain::{HeadData, BlockData, Id as ParaId, Message, Extrinsic}};
|
||||||
use collator::{InvalidHead, ParachainContext, VersionInfo};
|
use collator::{InvalidHead, ParachainContext, VersionInfo};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
|
||||||
@@ -49,6 +49,7 @@ impl ParachainContext for AdderContext {
|
|||||||
|
|
||||||
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
|
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
|
||||||
&self,
|
&self,
|
||||||
|
_relay_parent: Hash,
|
||||||
last_head: HeadData,
|
last_head: HeadData,
|
||||||
ingress: I,
|
ingress: I,
|
||||||
) -> Result<(BlockData, HeadData, Extrinsic), InvalidHead>
|
) -> Result<(BlockData, HeadData, Extrinsic), InvalidHead>
|
||||||
|
|||||||
Reference in New Issue
Block a user