Skip to content

Commit

Permalink
Merge pull request #280 from AurevoirXavier/genesis-time
Browse files Browse the repository at this point in the history
fix: #171
  • Loading branch information
hackfisher authored Feb 24, 2020
2 parents db93e24 + 9edd2da commit bd8be2f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
29 changes: 14 additions & 15 deletions bin/node/runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.

// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use std::{
env, fs,
path::Path,
time::{SystemTime, UNIX_EPOCH},
};

use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSource};

fn main() {
fs::write(
&Path::new(&env::var_os("OUT_DIR").unwrap()).join("timestamp_now.rs"),
&format!(
"pub const NOW: u64 = {};",
SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as u64,
),
)
.unwrap();

build_current_project_with_rustflags(
"wasm_binary.rs",
// TODO: update version
Expand Down
7 changes: 2 additions & 5 deletions bin/node/runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ pub mod time {
use node_primitives::{BlockNumber, Moment};
use sp_staking::SessionIndex;

/// Date in Los Angeles*: 19/02/2020, 03:30:00
/// Date in Berlin* :19/02/2020, 18:30:00
/// Date in Beijing*: 19/02/2020, 17:30:00
/// Date in New York* :19/02/2020, 05:30:00
pub const GENESIS_TIME: Moment = 1_582_108_200_000;
include!(concat!(env!("OUT_DIR"), "/timestamp_now.rs"));
pub const GENESIS_TIME: Moment = NOW;

/// Since BABE is probabilistic this is the average expected block time that
/// we are targetting. Blocks will be produced at a minimum duration defined
Expand Down

0 comments on commit bd8be2f

Please sign in to comment.