taking care of errors from ./test-check.sh

This commit is contained in:
Jon-Eric Cook
2020-01-27 15:30:06 -08:00
committed by Michael Vines
parent 8c6f7ee5a4
commit 1d32603b49

View File

@ -74,7 +74,7 @@ fn output_keypair(
} }
fn grind_validator_starts_with(v: String) -> Result<(), String> { fn grind_validator_starts_with(v: String) -> Result<(), String> {
if v.matches(":").count() != 1 || (v.starts_with(":") || v.ends_with(":")) { if v.matches(':').count() != 1 || (v.starts_with(':') || v.ends_with(':')) {
return Err(String::from("Expected : between PREFIX and COUNT")); return Err(String::from("Expected : between PREFIX and COUNT"));
} }
let args: Vec<&str> = v.split(':').collect(); let args: Vec<&str> = v.split(':').collect();
@ -89,7 +89,7 @@ fn grind_validator_starts_with(v: String) -> Result<(), String> {
} }
fn grind_validator_ends_with(v: String) -> Result<(), String> { fn grind_validator_ends_with(v: String) -> Result<(), String> {
if v.matches(":").count() != 1 || (v.starts_with(":") || v.ends_with(":")) { if v.matches(':').count() != 1 || (v.starts_with(':') || v.ends_with(':')) {
return Err(String::from("Expected : between SUFFIX and COUNT")); return Err(String::from("Expected : between SUFFIX and COUNT"));
} }
let args: Vec<&str> = v.split(':').collect(); let args: Vec<&str> = v.split(':').collect();
@ -104,7 +104,7 @@ fn grind_validator_ends_with(v: String) -> Result<(), String> {
} }
fn grind_validator_starts_and_ends_with(v: String) -> Result<(), String> { fn grind_validator_starts_and_ends_with(v: String) -> Result<(), String> {
if v.matches(":").count() != 2 || (v.starts_with(":") || v.ends_with(":")) { if v.matches(':').count() != 2 || (v.starts_with(':') || v.ends_with(':')) {
return Err(String::from( return Err(String::from(
"Expected : between PREFIX and SUFFIX and COUNT", "Expected : between PREFIX and SUFFIX and COUNT",
)); ));
@ -434,27 +434,25 @@ fn main() -> Result<(), Box<dyn error::Error>> {
} }
println!("Searching with {} threads for:", num_cpus::get()); println!("Searching with {} threads for:", num_cpus::get());
for i in 0..grind_matches.len() { for gm in &grind_matches {
let pk: String; let mut msg = Vec::<String>::new();
let st: String; if gm.count.load(Ordering::Relaxed) > 1 {
let en: String; msg.push("pubkeys".to_string());
if grind_matches[i].count.load(Ordering::Relaxed) > 1 { msg.push("start".to_string());
pk = "pubkeys".to_string(); msg.push("end".to_string());
st = "start".to_string();
en = "end".to_string();
} else { } else {
pk = "pubkey".to_string(); msg.push("pubkey".to_string());
st = "starts".to_string(); msg.push("starts".to_string());
en = "ends".to_string(); msg.push("ends".to_string());
} }
println!( println!(
"\t{} {} that {} with '{}' and {} with '{}'", "\t{} {} that {} with '{}' and {} with '{}'",
grind_matches[i].count.load(Ordering::Relaxed), gm.count.load(Ordering::Relaxed),
pk, msg[0],
st, msg[1],
grind_matches[i].starts, gm.starts,
en, msg[2],
grind_matches[i].ends gm.ends
); );
} }
@ -487,7 +485,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let mut total_matches_found = 0; let mut total_matches_found = 0;
for i in 0..grind_matches_thread_safe.len() { for i in 0..grind_matches_thread_safe.len() {
if grind_matches_thread_safe[i].count.load(Ordering::Relaxed) == 0 { if grind_matches_thread_safe[i].count.load(Ordering::Relaxed) == 0 {
total_matches_found = total_matches_found + 1; total_matches_found += 1;
continue; continue;
} }
if (!grind_matches_thread_safe[i].starts.is_empty() if (!grind_matches_thread_safe[i].starts.is_empty()