allow to specify schedule time as a relative value (#6578)

* allow to specify schedule time as a relative value

* bump version

* line width

* fix benchmarks

* rename and updates
This commit is contained in:
Xiliang Chen
2020-07-15 17:19:21 +12:00
committed by GitHub
parent c802d425d9
commit 8f4329823a
6 changed files with 169 additions and 39 deletions
+11 -2
View File
@@ -1490,6 +1490,15 @@ pub mod schedule {
/// higher priority.
pub type Priority = u8;
/// The dispatch time of a scheduled task.
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug)]
pub enum DispatchTime<BlockNumber> {
/// At specified block.
At(BlockNumber),
/// After specified number of blocks.
After(BlockNumber),
}
/// The highest priority. We invert the value so that normal sorting will place the highest
/// priority at the beginning of the list.
pub const HIGHEST_PRIORITY: Priority = 0;
@@ -1510,7 +1519,7 @@ pub mod schedule {
///
/// Infallible.
fn schedule(
when: BlockNumber,
when: DispatchTime<BlockNumber>,
maybe_periodic: Option<Period<BlockNumber>>,
priority: Priority,
origin: Origin,
@@ -1540,7 +1549,7 @@ pub mod schedule {
/// - `id`: The identity of the task. This must be unique and will return an error if not.
fn schedule_named(
id: Vec<u8>,
when: BlockNumber,
when: DispatchTime<BlockNumber>,
maybe_periodic: Option<Period<BlockNumber>>,
priority: Priority,
origin: Origin,