From fc2697e7d804b67c1aa5c3dc1226e056e775f85d Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Mon, 23 Jan 2017 14:34:02 -0800 Subject: [PATCH] When the cuckoo size is reduced for tests, pow needs to be recomputed for the genesis block. --- chain/src/types.rs | 2 +- grin/src/server.rs | 3 ++- grin/tests/simulnet.rs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chain/src/types.rs b/chain/src/types.rs index eebdcd69f..a94b95ce5 100644 --- a/chain/src/types.rs +++ b/chain/src/types.rs @@ -52,7 +52,7 @@ impl Tip { height: b.header.height, last_block_h: b.hash(), prev_block_h: b.header.previous, - total_difficulty: b.header.total_difficulty.clone() + Difficulty::from_hash(&b.hash()), + total_difficulty: b.header.total_difficulty.clone(), } } } diff --git a/grin/src/server.rs b/grin/src/server.rs index 5602ce130..f0f5b8354 100644 --- a/grin/src/server.rs +++ b/grin/src/server.rs @@ -96,7 +96,6 @@ impl Server { let handle = evtlp.handle(); evtlp.run(server.start(handle.clone())).unwrap(); - warn!("Grin server started."); Ok(Server { config: config, @@ -173,6 +172,8 @@ fn store_head(config: &ServerConfig) let mut gen = core::genesis::genesis(); if config.cuckoo_size > 0 { gen.header.cuckoo_len = config.cuckoo_size; + let diff = gen.header.difficulty.clone(); + core::pow::pow(&mut gen, diff).unwrap(); } try!(chain_store.save_block(&gen).map_err(&Error::StoreErr)); let tip = chain::types::Tip::new(gen.hash()); diff --git a/grin/tests/simulnet.rs b/grin/tests/simulnet.rs index 5d20837b2..4414100cc 100644 --- a/grin/tests/simulnet.rs +++ b/grin/tests/simulnet.rs @@ -77,7 +77,8 @@ fn change<'a>(s: &'a grin::Server) -> HeadChange<'a> { } } -/// Future that monitors when a server has had its head updated. +/// Future that monitors when a server has had its head updated. Current +/// implementation isn't optimized, only use for tests. struct HeadChange<'a> { server: &'a grin::Server, original: chain::Tip,