diff --git a/__crypto/btc-address/src/main.rs b/__crypto/btc-address/src/main.rs index dbcc646..b585307 100644 --- a/__crypto/btc-address/src/main.rs +++ b/__crypto/btc-address/src/main.rs @@ -30,14 +30,20 @@ fn main() { .unwrap_or_else(|_| 10_000_000_u64); println!("LOOP_COUNT={}", loop_count); + let num_of_vcpus = num_cpus::get(); let num_of_phycpus = num_cpus::get_physical(); println!("You have {} vCPUs, from {} phyCPUs", num_of_vcpus, num_of_phycpus); + let concurrent_count = std::env::var("CONCURRENT_COUNT") + .map(|c| c.parse::()) + .unwrap_or_else(|_| Ok(num_of_phycpus as u64)) + .unwrap_or_else(|_| 1_u64); + println!("CONCURRENT_COUNT={}", concurrent_count); let stop_flag = Arc::new(Mutex::new(false)); let mut handles = vec![]; - for ind in 0..num_of_phycpus { - println!("- Running task {} of {}", ind, num_of_phycpus); + for ind in 0..concurrent_count { + println!("- Running task {} of {}", ind, concurrent_count); let the_stop_flag = Arc::clone(&stop_flag); let prefixes = prefixes.clone(); let child = thread::spawn(move || { @@ -51,7 +57,7 @@ fn main() { println!("Finished!"); } -fn run_one_task(prefixes: Vec, continue_on_found: bool, loop_count: u64, ind: usize, the_stop_flag: Arc>) { +fn run_one_task(prefixes: Vec, continue_on_found: bool, loop_count: u64, ind: u64, the_stop_flag: Arc>) { let secp = Secp256k1::new(); let mut rng = OsRng::new().expect("OsRng");