Allow specify schedule dispatch origin (#6387)

* allow specify schedule dispatch origin

* fix tests

* use caller origin for scheduled

* fix tests

* line width

* check origin for cancel

* line width

* fix some issues for benchmarking

* fix doc test

* another way to constraint origin

* fix build issues

* fix cancel

* line width

* fix benchmarks

* bump version

* enable runtime upgrade

* add migration code and test

* Update frame/scheduler/src/lib.rs

Co-authored-by: Gavin Wood <github@gavwood.com>

* expose migration method

* add notes

* bump version

* remove on_runtime_upgrade

* fix test

Co-authored-by: Gavin Wood <github@gavwood.com>
This commit is contained in:
Xiliang Chen
2020-07-03 01:05:15 +12:00
committed by GitHub
parent 540ae1c161
commit e1d0f84c67
16 changed files with 510 additions and 139 deletions
+7 -2
View File
@@ -1500,7 +1500,7 @@ pub mod schedule {
pub const LOWEST_PRIORITY: Priority = 255;
/// A type that can be used as a scheduler.
pub trait Anon<BlockNumber, Call> {
pub trait Anon<BlockNumber, Call, Origin> {
/// An address which can be used for removing a scheduled task.
type Address: Codec + Clone + Eq + EncodeLike + Debug;
@@ -1513,6 +1513,7 @@ pub mod schedule {
when: BlockNumber,
maybe_periodic: Option<Period<BlockNumber>>,
priority: Priority,
origin: Origin,
call: Call
) -> Result<Self::Address, DispatchError>;
@@ -1530,7 +1531,7 @@ pub mod schedule {
}
/// A type that can be used as a scheduler.
pub trait Named<BlockNumber, Call> {
pub trait Named<BlockNumber, Call, Origin> {
/// An address which can be used for removing a scheduled task.
type Address: Codec + Clone + Eq + EncodeLike + sp_std::fmt::Debug;
@@ -1542,6 +1543,7 @@ pub mod schedule {
when: BlockNumber,
maybe_periodic: Option<Period<BlockNumber>>,
priority: Priority,
origin: Origin,
call: Call
) -> Result<Self::Address, ()>;
@@ -1605,6 +1607,9 @@ pub trait OriginTrait: Sized {
/// Filter the call, if false then call is filtered out.
fn filter_call(&self, call: &Self::Call) -> bool;
/// Get the caller.
fn caller(&self) -> &Self::PalletsOrigin;
}
/// Trait to be used when types are exactly same.