difftreelog
Comments and code description added
in: master
1 file changed
pallets/scheduler/src/lib.rsdiffbeforeafterboth46//! If a call is scheduled using proxy or whatever mecanism which adds filter,46//! If a call is scheduled using proxy or whatever mecanism which adds filter,47//! then those filter will not be used when dispatching the schedule call.47//! then those filter will not be used when dispatching the schedule call.48//!48//!49//! The scheduler is designed for deferred transaction calls by block number.50//! Any user can book a call of a certain transaction to a specific block number.51//! Also possible to book a call with a certain frequency.52//! Key differences from original pallet:53//! Id restricted by 16 bytes54//! Priority limited by HARD DEADLINE (<= 63). Calls over maximum weight don't include to block55//! Maybe_periodic limit is 100 calls56//! Any account allowed to schedule any calls. Account withdraw implemented through default transaction logic.57//! 49//! ## Interface58//! ## Interface50//!59//!51//! ### Dispatchable Functions60//! ### Dispatchable Functions143152144pub use preimage_provider::PreimageProviderAndMaybeRecipient;153pub use preimage_provider::PreimageProviderAndMaybeRecipient;145154155/// Weight templates for calculating actual fees146pub(crate) trait MarginalWeightInfo: WeightInfo {156pub(crate) trait MarginalWeightInfo: WeightInfo {147 fn item(periodic: bool, named: bool, resolved: Option<bool>) -> Weight {157 fn item(periodic: bool, named: bool, resolved: Option<bool>) -> Weight {148 match (periodic, named, resolved) {158 match (periodic, named, resolved) {249 /// If `Some` then the number of blocks to postpone execution for when the item is delayed.259 /// If `Some` then the number of blocks to postpone execution for when the item is delayed.250 type NoPreimagePostponement: Get<Option<Self::BlockNumber>>;260 type NoPreimagePostponement: Get<Option<Self::BlockNumber>>;251261252 /// Sponsoring function.262 /// Sponsoring function. In this version sposorship is disabled253 // type SponsorshipHandler: SponsorshipHandler<Self::AccountId, <Self as Config>::Call>;263 // type SponsorshipHandler: SponsorshipHandler<Self::AccountId, <Self as Config>::Call>;254264255 /// The helper type used for custom transaction fee logic.265 /// The helper type used for custom transaction fee logic.258268259 /// A Scheduler-Runtime interface for finer payment handling.269 /// A Scheduler-Runtime interface for finer payment handling.260 pub trait DispatchCall<T: frame_system::Config + Config, SelfContainedSignedInfo> {270 pub trait DispatchCall<T: frame_system::Config + Config, SelfContainedSignedInfo> {271 /// Lock balance required for transaction payment261 fn reserve_balance(272 fn reserve_balance(262 id: ScheduledId,273 id: ScheduledId,263 sponsor: <T as frame_system::Config>::AccountId,274 sponsor: <T as frame_system::Config>::AccountId,264 call: <T as Config>::Call,275 call: <T as Config>::Call,265 count: u32,276 count: u32,266 ) -> Result<(), DispatchError>;277 ) -> Result<(), DispatchError>;267278279 /// Unlock centain amount from payer 268 fn pay_for_call(280 fn pay_for_call(269 id: ScheduledId,281 id: ScheduledId,270 sponsor: <T as frame_system::Config>::AccountId,282 sponsor: <T as frame_system::Config>::AccountId,280 TransactionValidityError,292 TransactionValidityError,281 >;293 >;282294295 /// Cancel schedule reservation and unlock balance283 fn cancel_reserve(296 fn cancel_reserve(284 id: ScheduledId,297 id: ScheduledId,285 sponsor: <T as frame_system::Config>::AccountId,298 sponsor: <T as frame_system::Config>::AccountId,423 continue;436 continue;424 }437 }425438439 // Sender is the account who signed transaction426 let sender = ensure_signed(440 let sender = ensure_signed(427 <<T as Config>::Origin as From<T::PalletsOrigin>>::from(s.origin.clone())441 <<T as Config>::Origin as From<T::PalletsOrigin>>::from(s.origin.clone())428 .into(),442 .into(),438 // );452 // );439 // }453 // }440454455 // Execute transaction via chain default pipeline441 let r = T::CallExecutor::dispatch_call(sender, call.clone());456 let r = T::CallExecutor::dispatch_call(sender, call.clone());442457443 let mut actual_call_weight: Weight = item_weight;458 let mut actual_call_weight: Weight = item_weight;482 Agenda::<T>::append(wake, Some(s));497 Agenda::<T>::append(wake, Some(s));483 }498 }484 }499 }500 /// Weight should be 0, because transaction already paid 485 0501 0486 //total_weight487 }502 }488 }503 }489504