mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
When the cuckoo size is reduced for tests, pow needs to be recomputed for the genesis block.
This commit is contained in:
parent
18043cf94d
commit
fc2697e7d8
3 changed files with 5 additions and 3 deletions
|
@ -52,7 +52,7 @@ impl Tip {
|
||||||
height: b.header.height,
|
height: b.header.height,
|
||||||
last_block_h: b.hash(),
|
last_block_h: b.hash(),
|
||||||
prev_block_h: b.header.previous,
|
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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,6 @@ impl Server {
|
||||||
let handle = evtlp.handle();
|
let handle = evtlp.handle();
|
||||||
evtlp.run(server.start(handle.clone())).unwrap();
|
evtlp.run(server.start(handle.clone())).unwrap();
|
||||||
|
|
||||||
|
|
||||||
warn!("Grin server started.");
|
warn!("Grin server started.");
|
||||||
Ok(Server {
|
Ok(Server {
|
||||||
config: config,
|
config: config,
|
||||||
|
@ -173,6 +172,8 @@ fn store_head(config: &ServerConfig)
|
||||||
let mut gen = core::genesis::genesis();
|
let mut gen = core::genesis::genesis();
|
||||||
if config.cuckoo_size > 0 {
|
if config.cuckoo_size > 0 {
|
||||||
gen.header.cuckoo_len = config.cuckoo_size;
|
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));
|
try!(chain_store.save_block(&gen).map_err(&Error::StoreErr));
|
||||||
let tip = chain::types::Tip::new(gen.hash());
|
let tip = chain::types::Tip::new(gen.hash());
|
||||||
|
|
|
@ -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> {
|
struct HeadChange<'a> {
|
||||||
server: &'a grin::Server,
|
server: &'a grin::Server,
|
||||||
original: chain::Tip,
|
original: chain::Tip,
|
||||||
|
|
Loading…
Reference in a new issue