mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-08 04:11:08 +03:00
cleanup and simplify how we generate the genesis block in user_testing (and automated_testing) modes (#2986)
This commit is contained in:
parent
aa5c428eb1
commit
4bd3aa109d
3 changed files with 4 additions and 36 deletions
|
@ -22,7 +22,6 @@
|
||||||
use chrono::prelude::{TimeZone, Utc};
|
use chrono::prelude::{TimeZone, Utc};
|
||||||
|
|
||||||
use crate::core;
|
use crate::core;
|
||||||
use crate::global;
|
|
||||||
use crate::pow::{Difficulty, Proof, ProofOfWork};
|
use crate::pow::{Difficulty, Proof, ProofOfWork};
|
||||||
use crate::util;
|
use crate::util;
|
||||||
use crate::util::secp::constants::SINGLE_BULLET_PROOF_SIZE;
|
use crate::util::secp::constants::SINGLE_BULLET_PROOF_SIZE;
|
||||||
|
@ -38,10 +37,9 @@ use crate::keychain::BlindingFactor;
|
||||||
pub fn genesis_dev() -> core::Block {
|
pub fn genesis_dev() -> core::Block {
|
||||||
core::Block::with_header(core::BlockHeader {
|
core::Block::with_header(core::BlockHeader {
|
||||||
height: 0,
|
height: 0,
|
||||||
// previous: core::hash::Hash([0xff; 32]),
|
timestamp: Utc.ymd(1997, 8, 4).and_hms(0, 0, 0),
|
||||||
timestamp: global::get_genesis_timestamp(),
|
|
||||||
pow: ProofOfWork {
|
pow: ProofOfWork {
|
||||||
nonce: global::get_genesis_nonce(),
|
nonce: 0,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
@ -31,8 +31,6 @@ use crate::pow::{
|
||||||
/// different sets of parameters for different purposes,
|
/// different sets of parameters for different purposes,
|
||||||
/// e.g. CI, User testing, production values
|
/// e.g. CI, User testing, production values
|
||||||
use crate::util::RwLock;
|
use crate::util::RwLock;
|
||||||
use chrono::prelude::{TimeZone, Utc};
|
|
||||||
use chrono::{DateTime, Duration};
|
|
||||||
/// Define these here, as they should be developer-set, not really tweakable
|
/// Define these here, as they should be developer-set, not really tweakable
|
||||||
/// by users
|
/// by users
|
||||||
|
|
||||||
|
@ -313,34 +311,6 @@ pub fn is_floonet() -> bool {
|
||||||
ChainTypes::Floonet == *param_ref
|
ChainTypes::Floonet == *param_ref
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to get a nonce known to create a valid POW on
|
|
||||||
/// the genesis block, to prevent it taking ages. Should be fine for now
|
|
||||||
/// as the genesis block POW solution turns out to be the same for every new
|
|
||||||
/// block chain at the moment
|
|
||||||
pub fn get_genesis_nonce() -> u64 {
|
|
||||||
let param_ref = CHAIN_TYPE.read();
|
|
||||||
match *param_ref {
|
|
||||||
// won't make a difference
|
|
||||||
ChainTypes::AutomatedTesting => 0,
|
|
||||||
// Magic nonce for current genesis block at cuckatoo15
|
|
||||||
ChainTypes::UserTesting => 27944,
|
|
||||||
// Placeholder, obviously not the right value
|
|
||||||
ChainTypes::Floonet => 0,
|
|
||||||
// Placeholder, obviously not the right value
|
|
||||||
ChainTypes::Mainnet => 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Genesis block timestamp. Dependant on chain type.
|
|
||||||
pub fn get_genesis_timestamp() -> DateTime<Utc> {
|
|
||||||
let param_ref = CHAIN_TYPE.read();
|
|
||||||
match *param_ref {
|
|
||||||
ChainTypes::UserTesting => Utc::now(),
|
|
||||||
ChainTypes::AutomatedTesting => Utc::now() - Duration::minutes(60),
|
|
||||||
_ => Utc.ymd(1997, 8, 4).and_hms(0, 0, 0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Converts an iterator of block difficulty data to more a more manageable
|
/// Converts an iterator of block difficulty data to more a more manageable
|
||||||
/// vector and pads if needed (which will) only be needed for the first few
|
/// vector and pads if needed (which will) only be needed for the first few
|
||||||
/// blocks after genesis
|
/// blocks after genesis
|
||||||
|
|
|
@ -172,8 +172,8 @@ impl Server {
|
||||||
));
|
));
|
||||||
|
|
||||||
let genesis = match config.chain_type {
|
let genesis = match config.chain_type {
|
||||||
global::ChainTypes::AutomatedTesting => genesis::genesis_dev(),
|
global::ChainTypes::AutomatedTesting => pow::mine_genesis_block().unwrap(),
|
||||||
global::ChainTypes::UserTesting => genesis::genesis_dev(),
|
global::ChainTypes::UserTesting => pow::mine_genesis_block().unwrap(),
|
||||||
global::ChainTypes::Floonet => genesis::genesis_floo(),
|
global::ChainTypes::Floonet => genesis::genesis_floo(),
|
||||||
global::ChainTypes::Mainnet => genesis::genesis_main(),
|
global::ChainTypes::Mainnet => genesis::genesis_main(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue