Make collation an optional return (#1787)

This pr changes the collator interface function to return an optional
collation instead of a collation. This is required as the parachain
itself can fail to generate a valid collation for various reason. Now if
the collation fails it will return `None`.

Besides that the pr adds some `RuntimeDebug` derive for `ValidationData`
and removes some whitespaces.
This commit is contained in:
Bastian Köcher
2020-10-06 11:57:10 +02:00
committed by GitHub
parent 22e7d54f4d
commit a4662104db
7 changed files with 51 additions and 34 deletions
+2 -2
View File
@@ -276,7 +276,7 @@ pub struct Collation {
pub new_validation_code: Option<ValidationCode>,
/// The head-data produced as a result of execution.
pub head_data: HeadData,
/// Proof that this block is valid.
/// Proof to verify the state transition of the parachain.
pub proof_of_validity: PoV,
}
@@ -285,7 +285,7 @@ pub struct CollationGenerationConfig {
/// Collator's authentication key, so it can sign things.
pub key: CollatorPair,
/// Collation function.
pub collator: Box<dyn Fn(&ValidationData) -> Box<dyn Future<Output = Collation> + Unpin + Send> + Send + Sync>,
pub collator: Box<dyn Fn(&ValidationData) -> Box<dyn Future<Output = Option<Collation>> + Unpin + Send> + Send + Sync>,
/// The parachain that this collator collates for
pub para_id: ParaId,
}