git.delta.rocks / unique-network / refs/commits / 6f1c7288e602

difftreelog

fix canceling of scheduling operations

Daniel Shiposha2022-09-12parent: #76160bd.patch.diff
in: master

1 file changed

modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
369369
370 let mut total_weight: Weight = T::WeightInfo::on_initialize(0);370 let mut total_weight: Weight = T::WeightInfo::on_initialize(0);
371 for (order, (index, mut s)) in queued.into_iter().enumerate() {371 for (order, (index, mut s)) in queued.into_iter().enumerate() {
372 let named = if let Some(ref id) = s.maybe_id {372 let named = s.maybe_id.is_some();
373 Lookup::<T>::remove(id);
374 true
375 } else {
376 false
377 };
378373
379 let (call, maybe_completed) = s.call.resolved::<T::PreimageProvider>();374 let (call, maybe_completed) = s.call.resolved::<T::PreimageProvider>();
380 s.call = call;375 s.call = call;
492 s.maybe_periodic = None;487 s.maybe_periodic = None;
493 }488 }
494 let wake = now + period;489 let wake = now + period;
490 let is_canceled;
491
495 // If scheduled is named, place its information in `Lookup`492 // If scheduled is named, place its information in `Lookup`
496 if let Some(ref id) = s.maybe_id {493 if let Some(ref id) = s.maybe_id {
494 is_canceled = Lookup::<T>::get(id).is_none();
497 let wake_index = Agenda::<T>::decode_len(wake).unwrap_or(0);495 let wake_index = Agenda::<T>::decode_len(wake).unwrap_or(0);
496
497 if !is_canceled {
498 Lookup::<T>::insert(id, (wake, wake_index as u32));498 Lookup::<T>::insert(id, (wake, wake_index as u32));
499 }
499 }500 } else {
501 is_canceled = false;
502 }
503
504 if !is_canceled {
500 Agenda::<T>::append(wake, Some(s));505 Agenda::<T>::append(wake, Some(s));
506 }
501 }507 } else if let Some(ref id) = s.maybe_id {
508 Lookup::<T>::remove(id);
509 }
502 }510 }
503 // Total weight should be 0, because the transaction is already paid for511 // Total weight should be 0, because the transaction is already paid for
504 Weight::zero()512 Weight::zero()