grin/core/src/genesis.rs

94 lines
2.5 KiB
Rust
Raw Normal View History

// Copyright 2016 The Grin Developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2016-10-21 03:06:12 +03:00
//! Definition of the genesis block. Placeholder for now.
use time;
use core;
use consensus;
use core::target::Difficulty;
use global;
2016-10-21 03:06:12 +03:00
/// Genesis block definition for development networks. The proof of work size
/// is small enough to mine it on the fly, so it does not contain its own
/// proof of work solution. Can also be easily mutated for different tests.
pub fn genesis_dev() -> core::Block {
2016-10-21 03:06:12 +03:00
core::Block {
header: core::BlockHeader {
height: 0,
previous: core::hash::Hash([0xff; 32]),
2016-10-21 03:06:12 +03:00
timestamp: time::Tm {
2016-12-14 06:21:49 +03:00
tm_year: 1997 - 1900,
2016-10-21 03:06:12 +03:00
tm_mon: 7,
tm_mday: 4,
..time::empty_tm()
},
nonce: global::get_genesis_nonce(),
..Default::default()
},
inputs: vec![],
outputs: vec![],
kernels: vec![],
}
}
/// First testnet genesis block, still subject to change (especially the date,
/// will hopefully come before Christmas).
pub fn genesis_testnet1() -> core::Block {
core::Block {
header: core::BlockHeader {
height: 0,
previous: core::hash::Hash([0xff; 32]),
timestamp: time::Tm {
tm_year: 2017 - 1900,
tm_mon: 12,
tm_mday: 25,
..time::empty_tm()
},
nonce: 1,
pow: core::Proof::zero(consensus::PROOFSIZE),
..Default::default()
},
inputs: vec![],
outputs: vec![],
kernels: vec![],
}
}
/// Placeholder for mainnet genesis block, will definitely change before
/// release so no use trying to pre-mine it.
pub fn genesis_main() -> core::Block {
core::Block {
header: core::BlockHeader {
height: 0,
previous: core::hash::Hash([0xff; 32]),
timestamp: time::Tm {
tm_year: 2018 - 1900,
tm_mon: 7,
tm_mday: 14,
..time::empty_tm()
},
difficulty: Difficulty::from_num(1000),
total_difficulty: Difficulty::from_num(1000),
nonce: global::get_genesis_nonce(),
pow: core::Proof::zero(consensus::PROOFSIZE),
..Default::default()
2016-10-21 03:06:12 +03:00
},
inputs: vec![],
outputs: vec![],
kernels: vec![],
2016-10-21 03:06:12 +03:00
}
}