mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 21:01:05 +00:00
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:
@@ -233,7 +233,17 @@ async fn handle_new_activations<Context: SubsystemContext>(
|
||||
ctx.spawn("collation generation collation builder", Box::pin(async move {
|
||||
let persisted_validation_data_hash = validation_data.persisted.hash();
|
||||
|
||||
let collation = (task_config.collator)(&validation_data).await;
|
||||
let collation = match (task_config.collator)(&validation_data).await {
|
||||
Some(collation) => collation,
|
||||
None => {
|
||||
log::debug!(
|
||||
target: LOG_TARGET,
|
||||
"collator returned no collation on collate for para_id {}.",
|
||||
scheduled_core.para_id,
|
||||
);
|
||||
return
|
||||
}
|
||||
};
|
||||
|
||||
let pov_hash = collation.proof_of_validity.hash();
|
||||
|
||||
@@ -384,10 +394,10 @@ mod tests {
|
||||
struct TestCollator;
|
||||
|
||||
impl Future for TestCollator {
|
||||
type Output = Collation;
|
||||
type Output = Option<Collation>;
|
||||
|
||||
fn poll(self: Pin<&mut Self>, _cx: &mut FuturesContext) -> Poll<Self::Output> {
|
||||
Poll::Ready(test_collation())
|
||||
Poll::Ready(Some(test_collation()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user