Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

srml-timestamp: define max timestamp drift in millis #4077

Merged
merged 2 commits into from
Nov 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions srml/timestamp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
}

fn check_inherent(call: &Self::Call, data: &InherentData) -> result::Result<(), Self::Error> {
const MAX_TIMESTAMP_DRIFT: u64 = 60;
const MAX_TIMESTAMP_DRIFT_MILLIS: u64 = 30 * 1000;

let t: u64 = match call {
Call::set(ref t) => t.clone().saturated_into::<u64>(),
Expand All @@ -298,7 +298,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
let data = extract_inherent_data(data).map_err(|e| InherentError::Other(e))?;

let minimum = (Self::now() + T::MinimumPeriod::get()).saturated_into::<u64>();
if t > data + MAX_TIMESTAMP_DRIFT {
if t > data + MAX_TIMESTAMP_DRIFT_MILLIS {
Err(InherentError::Other("Timestamp too far in future to accept".into()))
} else if t < minimum {
Err(InherentError::ValidAtTimestamp(minimum))
Expand Down