mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 11:17:56 +00:00
pallet-scheduler: Send CallUnavailable event if the call isn't present (#1161)
The event was already send before, but it was done at the wrong position. The pull request all changes the `execute_dispatch` signature to highlight that there is only one error type. Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Javier Viola <javier@parity.io>
This commit is contained in:
@@ -1096,7 +1096,14 @@ impl<T: Config> Pallet<T> {
|
||||
|
||||
let (call, lookup_len) = match T::Preimages::peek(&task.call) {
|
||||
Ok(c) => c,
|
||||
Err(_) => return Err((Unavailable, Some(task))),
|
||||
Err(_) => {
|
||||
Self::deposit_event(Event::CallUnavailable {
|
||||
task: (when, agenda_index),
|
||||
id: task.maybe_id,
|
||||
});
|
||||
|
||||
return Err((Unavailable, Some(task)))
|
||||
},
|
||||
};
|
||||
|
||||
let _ = weight.try_consume(T::WeightInfo::service_task(
|
||||
@@ -1106,15 +1113,7 @@ impl<T: Config> Pallet<T> {
|
||||
));
|
||||
|
||||
match Self::execute_dispatch(weight, task.origin.clone(), call) {
|
||||
Err(Unavailable) => {
|
||||
debug_assert!(false, "Checked to exist with `peek`");
|
||||
Self::deposit_event(Event::CallUnavailable {
|
||||
task: (when, agenda_index),
|
||||
id: task.maybe_id,
|
||||
});
|
||||
Err((Unavailable, Some(task)))
|
||||
},
|
||||
Err(Overweight) if is_first => {
|
||||
Err(()) if is_first => {
|
||||
T::Preimages::drop(&task.call);
|
||||
Self::deposit_event(Event::PermanentlyOverweight {
|
||||
task: (when, agenda_index),
|
||||
@@ -1122,7 +1121,7 @@ impl<T: Config> Pallet<T> {
|
||||
});
|
||||
Err((Unavailable, Some(task)))
|
||||
},
|
||||
Err(Overweight) => Err((Overweight, Some(task))),
|
||||
Err(()) => Err((Overweight, Some(task))),
|
||||
Ok(result) => {
|
||||
Self::deposit_event(Event::Dispatched {
|
||||
task: (when, agenda_index),
|
||||
@@ -1162,11 +1161,13 @@ impl<T: Config> Pallet<T> {
|
||||
///
|
||||
/// NOTE: Only the weight for this function will be counted (origin lookup, dispatch and the
|
||||
/// call itself).
|
||||
///
|
||||
/// Returns an error if the call is overweight.
|
||||
fn execute_dispatch(
|
||||
weight: &mut WeightMeter,
|
||||
origin: T::PalletsOrigin,
|
||||
call: <T as Config>::RuntimeCall,
|
||||
) -> Result<DispatchResult, ServiceTaskError> {
|
||||
) -> Result<DispatchResult, ()> {
|
||||
let base_weight = match origin.as_system_ref() {
|
||||
Some(&RawOrigin::Signed(_)) => T::WeightInfo::execute_dispatch_signed(),
|
||||
_ => T::WeightInfo::execute_dispatch_unsigned(),
|
||||
@@ -1176,7 +1177,7 @@ impl<T: Config> Pallet<T> {
|
||||
let max_weight = base_weight.saturating_add(call_weight);
|
||||
|
||||
if !weight.can_consume(max_weight) {
|
||||
return Err(Overweight)
|
||||
return Err(())
|
||||
}
|
||||
|
||||
let dispatch_origin = origin.into();
|
||||
|
||||
Reference in New Issue
Block a user