add premined pow solution for cuckoo16/UserTesting (#260)

* add premined pow solution for cuckoo16/UserTesting
faster startup time

* only check premined solution on genesis block (height 0)
This commit is contained in:
AntiochP
2017-11-13 10:24:49 -05:00
committed by GitHub
parent 54dbda6bc2
commit 596bbd9b6e
3 changed files with 88 additions and 74 deletions
+70 -61
View File
@@ -48,7 +48,7 @@ pub const AUTOMATED_TESTING_COINBASE_MATURITY: u64 = 3;
pub const USER_TESTING_COINBASE_MATURITY: u64 = 3;
/// Mining parameter modes
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum MiningParameterMode {
/// For CI testing
AutomatedTesting,
@@ -105,21 +105,19 @@ pub fn coinbase_maturity() -> u64 {
/// Are we in automated testing mode?
pub fn is_automated_testing_mode() -> bool {
let param_ref = MINING_PARAMETER_MODE.read().unwrap();
if let MiningParameterMode::AutomatedTesting = *param_ref {
return true;
} else {
return false;
}
MiningParameterMode::AutomatedTesting == *param_ref
}
/// Are we in user testing mode?
pub fn is_user_testing_mode() -> bool {
let param_ref = MINING_PARAMETER_MODE.read().unwrap();
MiningParameterMode::UserTesting == *param_ref
}
/// Are we in production mode?
pub fn is_production_mode() -> bool {
let param_ref = MINING_PARAMETER_MODE.read().unwrap();
if let MiningParameterMode::Production = *param_ref {
return true;
} else {
return false;
}
MiningParameterMode::Production == *param_ref
}
@@ -135,60 +133,71 @@ pub fn get_genesis_nonce() -> u64 {
// won't make a difference
MiningParameterMode::AutomatedTesting => 0,
// Magic nonce for current genesis block at cuckoo16
MiningParameterMode::UserTesting => 22141,
MiningParameterMode::UserTesting => 27944,
// Magic nonce for current genesis at cuckoo30
MiningParameterMode::Production => 1429942738856787200,
}
}
/// Returns the genesis POW for production, because it takes far too long to
/// mine at production values
/// using the internal miner
/// Returns the genesis POW for cuckoo16 (UserTesting) and cuckoo30 (Production)
pub fn get_genesis_pow() -> [u32; 42] {
// TODO: This is diff 26, probably just want a 10: mine one
[
7444824,
11926557,
28520390,
30594072,
50854023,
52797085,
57882033,
59816511,
61404804,
84947619,
87779345,
115270337,
162618676,
166860710,
178656003,
178971372,
200454733,
209197630,
221231015,
228598741,
241012783,
245401183,
279080304,
295848517,
327300943,
329741709,
366394532,
382493153,
389329248,
404353381,
406012911,
418813499,
426573907,
452566575,
456930760,
463021458,
474340589,
476248039,
478197093,
487576917,
495653489,
501862896,
]
let param_ref = MINING_PARAMETER_MODE.read().unwrap();
match *param_ref {
// pow solution for genesis block at cuckoo16
MiningParameterMode::UserTesting => [
0x37f, 0x9f6, 0x136d, 0x13d3, 0x155e, 0x16dd, 0x186b, 0x1b11, 0x208e, 0x23cd,
0x24d1, 0x278f, 0x2a1b, 0x2a28, 0x2a44, 0x2ae2, 0x2c37, 0x36af, 0x391d, 0x3c2e,
0x3d9a, 0x3f00, 0x429f, 0x45b2, 0x47ce, 0x47f1, 0x492f, 0x4bd8, 0x4fee, 0x51f0,
0x5207, 0x58e5, 0x5905, 0x5aca, 0x5dfb, 0x628d, 0x7310, 0x75e5, 0x76d4, 0x76df,
0x77bd, 0x7ab9
],
// pow solution for genesis block at cuckoo30
// TODO - likely this is no longer correct (block header changes)
MiningParameterMode::Production => [
7444824,
11926557,
28520390,
30594072,
50854023,
52797085,
57882033,
59816511,
61404804,
84947619,
87779345,
115270337,
162618676,
166860710,
178656003,
178971372,
200454733,
209197630,
221231015,
228598741,
241012783,
245401183,
279080304,
295848517,
327300943,
329741709,
366394532,
382493153,
389329248,
404353381,
406012911,
418813499,
426573907,
452566575,
456930760,
463021458,
474340589,
476248039,
478197093,
487576917,
495653489,
501862896,
],
// TODO - for completeness do we provide one here for AutomatedTesting?
_ => panic!("unexpected"),
}
}