Skip to content

Commit a9983cd

Browse files
authored
prepping for releasing rc6 (#6922)
* Bump version * update test-utils crates to be ready for publishing * adding changelog * Adding automaticly generated READMEs * fixing versions * another version mishap
1 parent 74362ee commit a9983cd

File tree

2 files changed

+85
-11
lines changed

2 files changed

+85
-11
lines changed

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pallet-timestamp"
3-
version = "2.0.0-rc5"
3+
version = "2.0.0-rc6"
44
authors = ["Parity Technologies <admin@parity.io>"]
55
edition = "2018"
66
license = "Apache-2.0"
@@ -16,19 +16,19 @@ targets = ["x86_64-unknown-linux-gnu"]
1616
[dependencies]
1717
serde = { version = "1.0.101", optional = true }
1818
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
19-
sp-std = { version = "2.0.0-rc5", default-features = false, path = "../../primitives/std" }
20-
sp-io = { version = "2.0.0-rc5", default-features = false, path = "../../primitives/io", optional = true }
21-
sp-runtime = { version = "2.0.0-rc5", default-features = false, path = "../../primitives/runtime" }
22-
sp-inherents = { version = "2.0.0-rc5", default-features = false, path = "../../primitives/inherents" }
23-
frame-benchmarking = { version = "2.0.0-rc5", default-features = false, path = "../benchmarking", optional = true }
24-
frame-support = { version = "2.0.0-rc5", default-features = false, path = "../support" }
25-
frame-system = { version = "2.0.0-rc5", default-features = false, path = "../system" }
26-
sp-timestamp = { version = "2.0.0-rc5", default-features = false, path = "../../primitives/timestamp" }
19+
sp-std = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/std" }
20+
sp-io = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/io", optional = true }
21+
sp-runtime = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/runtime" }
22+
sp-inherents = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/inherents" }
23+
frame-benchmarking = { version = "2.0.0-rc6", default-features = false, path = "../benchmarking", optional = true }
24+
frame-support = { version = "2.0.0-rc6", default-features = false, path = "../support" }
25+
frame-system = { version = "2.0.0-rc6", default-features = false, path = "../system" }
26+
sp-timestamp = { version = "2.0.0-rc6", default-features = false, path = "../../primitives/timestamp" }
2727
impl-trait-for-tuples = "0.1.3"
2828

2929
[dev-dependencies]
30-
sp-io ={ version = "2.0.0-rc5", path = "../../primitives/io" }
31-
sp-core = { version = "2.0.0-rc5", path = "../../primitives/core" }
30+
sp-io ={ version = "2.0.0-rc6", path = "../../primitives/io" }
31+
sp-core = { version = "2.0.0-rc6", path = "../../primitives/core" }
3232

3333
[features]
3434
default = ["std"]

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Timestamp Module
2+
3+
The Timestamp module provides functionality to get and set the on-chain time.
4+
5+
- [`timestamp::Trait`](./trait.Trait.html)
6+
- [`Call`](./enum.Call.html)
7+
- [`Module`](./struct.Module.html)
8+
9+
## Overview
10+
11+
The Timestamp module allows the validators to set and validate a timestamp with each block.
12+
13+
It uses inherents for timestamp data, which is provided by the block author and validated/verified
14+
by other validators. The timestamp can be set only once per block and must be set each block.
15+
There could be a constraint on how much time must pass before setting the new timestamp.
16+
17+
**NOTE:** The Timestamp module is the recommended way to query the on-chain time instead of using
18+
an approach based on block numbers. The block number based time measurement can cause issues
19+
because of cumulative calculation errors and hence should be avoided.
20+
21+
## Interface
22+
23+
### Dispatchable Functions
24+
25+
* `set` - Sets the current time.
26+
27+
### Public functions
28+
29+
* `get` - Gets the current time for the current block. If this function is called prior to
30+
setting the timestamp, it will return the timestamp of the previous block.
31+
32+
### Trait Getters
33+
34+
* `MinimumPeriod` - Gets the minimum (and advised) period between blocks for the chain.
35+
36+
## Usage
37+
38+
The following example shows how to use the Timestamp module in your custom module to query the current timestamp.
39+
40+
### Prerequisites
41+
42+
Import the Timestamp module into your custom module and derive the module configuration
43+
trait from the timestamp trait.
44+
45+
### Get current timestamp
46+
47+
```rust
48+
use frame_support::{decl_module, dispatch};
49+
use frame_system::ensure_signed;
50+
51+
pub trait Trait: timestamp::Trait {}
52+
53+
decl_module! {
54+
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
55+
#[weight = 0]
56+
pub fn get_time(origin) -> dispatch::DispatchResult {
57+
let _sender = ensure_signed(origin)?;
58+
let _now = <timestamp::Module<T>>::get();
59+
Ok(())
60+
}
61+
}
62+
}
63+
```
64+
65+
### Example from the FRAME
66+
67+
The [Session module](https://github.com/paritytech/substrate/blob/master/frame/session/src/lib.rs) uses
68+
the Timestamp module for session management.
69+
70+
## Related Modules
71+
72+
* [Session](../pallet_session/index.html)
73+
74+
License: Apache-2.0

0 commit comments

Comments
 (0)