19
19
//!
20
20
//! The Timestamp module provides functionality to get and set the on-chain time.
21
21
//!
22
- //! - [`timestamp::Trait `](./trait.Trait .html)
22
+ //! - [`timestamp::Config `](./trait.Config .html)
23
23
//! - [`Call`](./enum.Call.html)
24
24
//! - [`Module`](./struct.Module.html)
25
25
//!
46
46
//! * `get` - Gets the current time for the current block. If this function is called prior to
47
47
//! setting the timestamp, it will return the timestamp of the previous block.
48
48
//!
49
- //! ### Trait Getters
49
+ //! ### Config Getters
50
50
//!
51
51
//! * `MinimumPeriod` - Gets the minimum (and advised) period between blocks for the chain.
52
52
//!
66
66
//! # use pallet_timestamp as timestamp;
67
67
//! use frame_system::ensure_signed;
68
68
//!
69
- //! pub trait Trait : timestamp::Trait {}
69
+ //! pub trait Config : timestamp::Config {}
70
70
//!
71
71
//! decl_module! {
72
- //! pub struct Module<T: Trait > for enum Call where origin: T::Origin {
72
+ //! pub struct Module<T: Config > for enum Call where origin: T::Origin {
73
73
//! #[weight = 0]
74
74
//! pub fn get_time(origin) -> dispatch::DispatchResult {
75
75
//! let _sender = ensure_signed(origin)?;
@@ -118,7 +118,7 @@ use sp_timestamp::{
118
118
pub use weights:: WeightInfo ;
119
119
120
120
/// The module configuration trait
121
- pub trait Trait : frame_system:: Trait {
121
+ pub trait Config : frame_system:: Config {
122
122
/// Type used for expressing timestamp.
123
123
type Moment : Parameter + Default + AtLeast32Bit
124
124
+ Scale < Self :: BlockNumber , Output = Self :: Moment > + Copy ;
@@ -137,7 +137,7 @@ pub trait Trait: frame_system::Trait {
137
137
}
138
138
139
139
decl_module ! {
140
- pub struct Module <T : Trait > for enum Call where origin: T :: Origin {
140
+ pub struct Module <T : Config > for enum Call where origin: T :: Origin {
141
141
/// The minimum period between blocks. Beware that this is different to the *expected* period
142
142
/// that the block production apparatus provides. Your chosen consensus system will generally
143
143
/// work with this to determine a sensible block time. e.g. For Aura, it will be double this
@@ -194,7 +194,7 @@ decl_module! {
194
194
}
195
195
196
196
decl_storage ! {
197
- trait Store for Module <T : Trait > as Timestamp {
197
+ trait Store for Module <T : Config > as Timestamp {
198
198
/// Current time for the current block.
199
199
pub Now get( fn now) : T :: Moment ;
200
200
@@ -203,7 +203,7 @@ decl_storage! {
203
203
}
204
204
}
205
205
206
- impl < T : Trait > Module < T > {
206
+ impl < T : Config > Module < T > {
207
207
/// Get the current time for the current block.
208
208
///
209
209
/// NOTE: if this function is called prior to setting the timestamp,
@@ -225,7 +225,7 @@ fn extract_inherent_data(data: &InherentData) -> Result<InherentType, RuntimeStr
225
225
. ok_or_else ( || "Timestamp inherent data is not provided." . into ( ) )
226
226
}
227
227
228
- impl < T : Trait > ProvideInherent for Module < T > {
228
+ impl < T : Config > ProvideInherent for Module < T > {
229
229
type Call = Call < T > ;
230
230
type Error = InherentError ;
231
231
const INHERENT_IDENTIFIER : InherentIdentifier = INHERENT_IDENTIFIER ;
@@ -260,7 +260,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
260
260
}
261
261
}
262
262
263
- impl < T : Trait > Time for Module < T > {
263
+ impl < T : Config > Time for Module < T > {
264
264
type Moment = T :: Moment ;
265
265
266
266
/// Before the first set of now with inherent the value returned is zero.
@@ -272,7 +272,7 @@ impl<T: Trait> Time for Module<T> {
272
272
/// Before the timestamp inherent is applied, it returns the time of previous block.
273
273
///
274
274
/// On genesis the time returned is not valid.
275
- impl < T : Trait > UnixTime for Module < T > {
275
+ impl < T : Config > UnixTime for Module < T > {
276
276
fn now ( ) -> core:: time:: Duration {
277
277
// now is duration since unix epoch in millisecond as documented in
278
278
// `sp_timestamp::InherentDataProvider`.
@@ -314,7 +314,7 @@ mod tests {
314
314
pub const MaximumBlockLength : u32 = 2 * 1024 ;
315
315
pub const AvailableBlockRatio : Perbill = Perbill :: one( ) ;
316
316
}
317
- impl frame_system:: Trait for Test {
317
+ impl frame_system:: Config for Test {
318
318
type BaseCallFilter = ( ) ;
319
319
type Origin = Origin ;
320
320
type Index = u64 ;
@@ -344,7 +344,7 @@ mod tests {
344
344
parameter_types ! {
345
345
pub const MinimumPeriod : u64 = 5 ;
346
346
}
347
- impl Trait for Test {
347
+ impl Config for Test {
348
348
type Moment = u64 ;
349
349
type OnTimestampSet = ( ) ;
350
350
type MinimumPeriod = MinimumPeriod ;
0 commit comments