git.delta.rocks / unique-network / refs/commits / 8443538fb809

difftreelog

refactor(scheduler) id restricted to 16 bytes [CORE-245]

Fahrrader2022-01-11parent: #fcf0631.patch.diff
in: master

1 file changed

modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
76use up_sponsorship::SponsorshipHandler;76use up_sponsorship::SponsorshipHandler;
77use scale_info::TypeInfo;77use scale_info::TypeInfo;
78
79pub const MAX_TASK_ID_LENGTH_IN_BYTES: u32 = 16;
7880
79/// Our pallet's configuration trait. All our types and constants go in here. If the81/// Our pallet's configuration trait. All our types and constants go in here. If the
80/// pallet is dependent on specific other pallets, then their configuration traits82/// pallet is dependent on specific other pallets, then their configuration traits
569 origin: T::PalletsOrigin,571 origin: T::PalletsOrigin,
570 call: <T as Config>::Call,572 call: <T as Config>::Call,
571 ) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {573 ) -> Result<TaskAddress<T::BlockNumber>, DispatchError> {
572 // ensure id it is unique574 // ensure id length does not exceed expectations & is unique
573 if Lookup::<T>::contains_key(&id) {575 if id.len() > MAX_TASK_ID_LENGTH_IN_BYTES.try_into().unwrap()
576 || Lookup::<T>::contains_key(&id)
577 {
574 return Err(Error::<T>::FailedToSchedule.into());578 return Err(Error::<T>::FailedToSchedule.into());
575 }579 }
792 }796 }
793797
794 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;798 type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
799 // todo check current cumulus implementation, add changes accordingly, do something with signedExtra and (un)checked extrinsic (integral to Scheduler?)
800 // todo to include pallet in runtime, not only uncomment but also (implement?) trait
795 type Block = frame_system::mocking::MockBlock<Test>;801 type Block = frame_system::mocking::MockBlock<Test>;
796802
797 frame_support::construct_runtime!(803 frame_support::construct_runtime!(