Fixed panic when you try to mine genesis with existing origin hash in config.

This commit is contained in:
Revertron
2021-02-17 12:35:26 +01:00
parent c5bbf1b772
commit f28bedb8a1
+7 -1
View File
@@ -136,8 +136,14 @@ impl Miner {
} }
}, },
Some(block) => { Some(block) => {
let index = block.index;
let mut context = context.lock().unwrap(); let mut context = context.lock().unwrap();
context.blockchain.add_block(block).expect("Error adding fresh mined block!"); if context.blockchain.add_block(block).is_err() {
println!("Error adding mined block!");
if index == 0 {
println!("To mine genesis block you need to make 'origin' an empty string in config.");
}
}
context.bus.post(Event::MinerStopped); context.bus.post(Event::MinerStopped);
mining.store(false, Ordering::Relaxed); mining.store(false, Ordering::Relaxed);
}, },