Throw a compile error for on_finalise and on_initialise (#2236)

This commit is contained in:
Bastian Köcher
2019-04-09 10:31:18 +02:00
committed by GitHub
parent e57e54ab9c
commit 0afc357a97
3 changed files with 65 additions and 30 deletions
+30 -30
View File
@@ -15,49 +15,49 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
//! # Timestamp Module
//!
//! The timestamp module provides functionality to get and set the on-chain time.
//! To use it in your module, you need to implement the timestamp [`Trait`].
//! The supported dispatchable functions are documented as part of the [`Call`] enum.
//!
//! ## Overview
//!
//! The timestamp module allows the validators to set and validate a timestamp with each block.
//!
//! It uses inherents for timestamp data, which is provided by the block author and validated/verified by other validators.
//! The timestamp module provides functionality to get and set the on-chain time.
//! To use it in your module, you need to implement the timestamp [`Trait`].
//! The supported dispatchable functions are documented as part of the [`Call`] enum.
//!
//! ## Overview
//!
//! The timestamp module allows the validators to set and validate a timestamp with each block.
//!
//! It uses inherents for timestamp data, which is provided by the block author and validated/verified by other validators.
//! The timestamp can be set only once per block and must be set each block. There could be a constraint on how much time must pass before setting the new timestamp.
//!
//! **NOTE:** The timestamp module is the recommended way to query the on-chain time instead of using an approach based on block numbers.
//!
//! **NOTE:** The timestamp module is the recommended way to query the on-chain time instead of using an approach based on block numbers.
//! The block numbers based time measurement can cause issues because of cummulative calculation errors and hence it should be avoided.
//!
//!
//! ## Interface
//!
//!
//! ### Dispatchable functions ([`Call`])
//!
//!
//! * `set` - Sets the current time.
//!
//!
//! ### Public functions ([`Module`])
//!
//!
//! * `get` - Gets the current time for the current block. If this function is called prior the setting to timestamp, it will return the timestamp of the previous block.
//!
//!
//! * `minimum_period` - Gets the minimum (and advised) period between blocks for the chain.
//!
//!
//! ## Usage
//!
//!
//! The following example shows how to use the timestamp module in your custom module to query the current timestamp.
//!
//!
//! ### Prerequisites
//!
//!
//! Import the `timestamp` module in your custom module and derive the module configuration trait from the `timestamp` trait.
//!
//!
//! ### Get current timestamp
//!
//!
//! ```ignore
//! use support::{decl_module, dispatch::Result};
//! use system::ensure_signed;
//!
//!
//! pub trait Trait: timestamp::Trait {}
//!
//!
//! decl_module! {
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
//! pub fn get_time(origin) -> Result {
@@ -68,13 +68,13 @@
//! }
//! }
//! ```
//!
//!
//! ### Example from SRML
//!
//!
//! The [`Session` module](https://github.com/paritytech/substrate/blob/master/srml/session/src/lib.rs) uses the `timestamp` module for session management.
//!
//!
//! ## Related Modules
//!
//!
//! * [`System`](https://crates.parity.io/srml_system/index.html)
//! * [`Session`](https://crates.parity.io/srml_session/index.html)
//!
@@ -212,7 +212,7 @@ decl_module! {
/// if this call hasn't been invoked by that time.
///
/// The timestamp should be greater than the previous one by the amount specified by `minimum_period`.
///
///
/// The dispatch origin for this call must be `Inherent`.
fn set(origin, #[compact] now: T::Moment) {
ensure_inherent(origin)?;