From f28bedb8a1ecb5612408582dfc3f941d5ea090b9 Mon Sep 17 00:00:00 2001 From: Revertron Date: Wed, 17 Feb 2021 12:35:26 +0100 Subject: [PATCH] Fixed panic when you try to mine genesis with existing origin hash in config. --- src/miner.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/miner.rs b/src/miner.rs index 7814d33..0091ad5 100644 --- a/src/miner.rs +++ b/src/miner.rs @@ -136,8 +136,14 @@ impl Miner { } }, Some(block) => { + let index = block.index; 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); mining.store(false, Ordering::Relaxed); },