mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
Feedback from @XLC for Referenda Pallet (#10991)
* feedback from @xlc * english * fmt Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{DispatchError, RuntimeDebug};
|
||||
use sp_runtime::{traits::Saturating, DispatchError, RuntimeDebug};
|
||||
use sp_std::{fmt::Debug, prelude::*, result::Result};
|
||||
|
||||
/// Information relating to the period of a scheduled task. First item is the length of the
|
||||
@@ -32,7 +32,7 @@ pub type Period<BlockNumber> = (BlockNumber, u32);
|
||||
pub type Priority = u8;
|
||||
|
||||
/// The dispatch time of a scheduled task.
|
||||
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
pub enum DispatchTime<BlockNumber> {
|
||||
/// At specified block.
|
||||
At(BlockNumber),
|
||||
@@ -40,6 +40,15 @@ pub enum DispatchTime<BlockNumber> {
|
||||
After(BlockNumber),
|
||||
}
|
||||
|
||||
impl<BlockNumber: Saturating + Copy> DispatchTime<BlockNumber> {
|
||||
pub fn evaluate(&self, since: BlockNumber) -> BlockNumber {
|
||||
match &self {
|
||||
Self::At(m) => *m,
|
||||
Self::After(m) => m.saturating_add(since),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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;
|
||||
|
||||
Reference in New Issue
Block a user