feat: add num_cpus
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
use std::{
|
||||
thread,
|
||||
sync::{ Arc, Mutex, },
|
||||
};
|
||||
use std::{ thread, sync::{ Arc, Mutex } };
|
||||
use rand::rngs::OsRng;
|
||||
use secp256k1::{ Secp256k1, key::PublicKey, };
|
||||
use secp256k1::{ Secp256k1, key::PublicKey };
|
||||
use sha2::Sha256;
|
||||
use ripemd160::Ripemd160;
|
||||
use digest::{ Input, FixedOutput, };
|
||||
use digest::{ Input, FixedOutput };
|
||||
|
||||
const PREFIX: &[&str] = &["1Hatter"];
|
||||
|
||||
fn main() {
|
||||
println!("Prefix: {:?}", PREFIX);
|
||||
|
||||
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 stop_flag = Arc::new(Mutex::new(false));
|
||||
let mut handles = vec![];
|
||||
for ind in 0..4 {
|
||||
for ind in 0..num_of_phycpus {
|
||||
println!("- Running task {} of {}", ind, num_of_phycpus);
|
||||
let the_stop_flag = Arc::clone(&stop_flag);
|
||||
let child = thread::spawn(move || {
|
||||
run_one_task(ind, the_stop_flag);
|
||||
@@ -37,7 +39,7 @@ fn run_one_task(ind: usize, the_stop_flag: Arc<Mutex<bool>>) {
|
||||
|
||||
let s = make_btc_address(&public_key);
|
||||
|
||||
if i % 10_000 == 0 {
|
||||
if i % 1_000 == 0 {
|
||||
if *the_stop_flag.lock().unwrap() {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user