use multi thread

This commit is contained in:
2020-04-19 23:34:55 +08:00
parent 0946d22fd9
commit 4eea25af9d

View File

@@ -1,3 +1,4 @@
use std::thread;
use rand::rngs::OsRng;
use secp256k1::{Secp256k1, key::PublicKey, };
use sha2::Sha256;
@@ -5,6 +6,20 @@ use ripemd160::Ripemd160;
use digest::{ Input, FixedOutput, };
fn main() {
let mut handles = vec![];
for ind in 0..8 {
let child = thread::spawn(move || {
run_one_task(ind);
});
handles.push(child);
}
while let Some(h) = handles.pop() {
h.join().unwrap();
}
println!("Finished!");
}
fn run_one_task(ind: usize) {
let secp = Secp256k1::new();
let mut rng = OsRng::new().expect("OsRng");
@@ -14,9 +29,9 @@ fn main() {
let s = make_btc_address(&public_key);
if i > 0 && i % 10000 == 0 {
println!("> {}", i);
println!("> {} - {}", ind, i);
}
if s.starts_with("100") {
if s.starts_with("1Hatt") {
println!("{}", s);
println!("{}", secret_key);
}