From 42b5d938a87b3a3cf783bae0001fe8d9474a388c Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Tue, 4 Jul 2023 09:24:33 +0200 Subject: [PATCH] Revert "Simplify handling of default difficulty" --- src/cli.rs | 2 +- src/lib.rs | 2 -- src/main.rs | 10 +++++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 93883b0..0befadd 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -26,7 +26,7 @@ pub struct CLIArgs { #[arg( short, long, - default_value_t = crate::DIFFICULTY_DEFAULT, + default_value_t = 0, help = "Enter the number of starting bits that should be 0." )] pub difficulty: u8, diff --git a/src/lib.rs b/src/lib.rs index 321f593..4cfdacd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,5 +2,3 @@ pub mod cli; pub mod mnemonic; pub mod tests; pub mod utils; - -pub(crate) const DIFFICULTY_DEFAULT: u8 = 10; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 874895f..6c31b23 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,7 @@ use rana::cli::*; use rana::mnemonic::handle_mnemonic; use rana::utils::{benchmark_cores, get_leading_zero_bits, print_divider, print_keys, print_qr}; +const DIFFICULTY_DEFAULT: u8 = 10; const BECH32_PREFIX: &str = "npub1"; fn main() -> Result<()> { @@ -23,7 +24,7 @@ fn main() -> Result<()> { handle_mnemonic(&parsed_args); } - let difficulty: u8 = parsed_args.difficulty; + let mut difficulty: u8 = parsed_args.difficulty; let vanity_prefix: String = parsed_args.vanity_prefix; let mut vanity_npub_prefixes: Vec = Vec::new(); let mut vanity_npub_suffixes: Vec = Vec::new(); @@ -80,6 +81,13 @@ fn main() -> Result<()> { ); } else { // Defaults to using difficulty + + // if difficulty not indicated, then assume default + if difficulty == 0 { + difficulty = DIFFICULTY_DEFAULT; // default + pow_difficulty = difficulty; + } + println!( "Started mining process with a difficulty of: {difficulty} (pow: {pow_difficulty})" );