Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Simplify handling of default difficulty" #43

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ pub mod cli;
pub mod mnemonic;
pub mod tests;
pub mod utils;

pub(crate) const DIFFICULTY_DEFAULT: u8 = 10;
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand All @@ -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<String> = Vec::new();
let mut vanity_npub_suffixes: Vec<String> = Vec::new();
Expand Down Expand Up @@ -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})"
);
Expand Down