mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
drew.tupletimestamp - Add tuple macro for timestamps too, break macro out into support (#1372)
* Add tuple and dont mess up spacing * Update lib.rs * Add timestamp tuple macro : * Tabs * Add docs.
This commit is contained in:
@@ -55,25 +55,31 @@ use runtime_primitives::traits::{
|
||||
};
|
||||
use system::ensure_inherent;
|
||||
use rstd::{result, ops::{Mul, Div}, vec::Vec};
|
||||
use runtime_support::for_each_tuple;
|
||||
|
||||
/// A trait which is called when the timestamp is set.
|
||||
pub trait OnTimestampSet<Moment> {
|
||||
fn on_timestamp_set(moment: Moment);
|
||||
}
|
||||
|
||||
impl<Moment> OnTimestampSet<Moment> for () {
|
||||
fn on_timestamp_set(_moment: Moment) { }
|
||||
}
|
||||
macro_rules! impl_timestamp_set {
|
||||
() => (
|
||||
impl<Moment> OnTimestampSet<Moment> for () {
|
||||
fn on_timestamp_set(_: Moment) {}
|
||||
}
|
||||
);
|
||||
|
||||
impl<A, B, Moment: Clone> OnTimestampSet<Moment> for (A, B)
|
||||
where A: OnTimestampSet<Moment>, B: OnTimestampSet<Moment>
|
||||
{
|
||||
fn on_timestamp_set(moment: Moment) {
|
||||
A::on_timestamp_set(moment.clone());
|
||||
B::on_timestamp_set(moment);
|
||||
( $($t:ident)* ) => {
|
||||
impl<Moment: Clone, $($t: OnTimestampSet<Moment>),*> OnTimestampSet<Moment> for ($($t,)*) {
|
||||
fn on_timestamp_set(moment: Moment) {
|
||||
$($t::on_timestamp_set(moment.clone());)*
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for_each_tuple!(impl_timestamp_set);
|
||||
|
||||
pub trait Trait: consensus::Trait + system::Trait {
|
||||
/// The position of the required timestamp-set extrinsic.
|
||||
const TIMESTAMP_SET_POSITION: u32;
|
||||
|
||||
Reference in New Issue
Block a user