pallet-scheduler: Unrequest call on failed lookup (#3849)

When the scheduler fails to lookup a `call`, it should unrequest it,
because it will not be required anymore.
This commit is contained in:
Bastian Köcher
2024-03-27 23:02:37 +00:00
committed by GitHub
parent bbdbeb7ec6
commit 597ea9203a
3 changed files with 28 additions and 0 deletions
+11
View File
@@ -1267,6 +1267,17 @@ impl<T: Config> Pallet<T> {
id: task.maybe_id,
});
// It was not available when we needed it, so we don't need to have requested it
// anymore.
T::Preimages::drop(&task.call);
// We don't know why `peek` failed, thus we most account here for the "full weight".
let _ = weight.try_consume(T::WeightInfo::service_task(
task.call.lookup_len().map(|x| x as usize),
task.maybe_id.is_some(),
task.maybe_periodic.is_some(),
));
return Err((Unavailable, Some(task)))
},
};