|
|
@@ -13,33 +13,44 @@ pub fn main() {
|
|
13
|
13
|
let diff = matches.value_of("difficulty").unwrap_or("1");
|
|
14
|
14
|
let mut time_measurement = false;
|
|
15
|
15
|
|
|
16
|
|
- println!("Using base: {}", base);
|
|
17
|
|
- println!("Using difficulty: {}", diff);
|
|
18
|
|
-
|
|
19
|
16
|
if diff.chars().any( |c| !c.is_digit(16)) {
|
|
20
|
17
|
println!("Difficulty is not hexadecimal.");
|
|
21
|
18
|
process::exit(1)
|
|
22
|
19
|
}
|
|
23
|
20
|
|
|
24
|
|
- if let Some(_) = matches.subcommand {
|
|
25
|
|
- time_measurement = true;
|
|
|
21
|
+ if let Some(ref sub_command) = matches.subcommand {
|
|
|
22
|
+ if sub_command.name.eq("timings") {
|
|
|
23
|
+ time_measurement = true;
|
|
|
24
|
+ }
|
|
26
|
25
|
}
|
|
27
|
26
|
|
|
28
|
27
|
match base.parse::<usize>() {
|
|
29
|
28
|
Ok(b) => {
|
|
|
29
|
+ println!("Using base: {}", base);
|
|
|
30
|
+ println!("Using difficulty: {}", diff);
|
|
30
|
31
|
println!("Please wait...");
|
|
31
|
32
|
let start = get_time();
|
|
32
|
|
- for n in 0..<usize>::max_value() {
|
|
|
33
|
+
|
|
|
34
|
+ let max = <usize>::max_value();
|
|
|
35
|
+ for n in 0..max {
|
|
33
|
36
|
if let Some(x) = hash256::verify_product(b, n, &diff.to_string()) {
|
|
34
|
37
|
let end = get_time();
|
|
35
|
|
- let diff = end - start;
|
|
36
|
38
|
println!("Number: {} --> hash: {}", x.number, x.hash);
|
|
37
|
|
- println!("(Duration {}s / {}ms / {}us)", diff.num_seconds(), diff.num_milliseconds(), diff.num_microseconds().unwrap_or(0));
|
|
|
39
|
+ if time_measurement{
|
|
|
40
|
+ let diff = end - start;
|
|
|
41
|
+ let s = diff.num_seconds();
|
|
|
42
|
+ let ms = diff.num_milliseconds();
|
|
|
43
|
+ let us = diff.num_microseconds().unwrap_or(ms * 1000);
|
|
|
44
|
+ println!("(Duration {}s / {}ms / {}us)", s, ms, us);
|
|
|
45
|
+ }
|
|
38
|
46
|
process::exit(0)
|
|
39
|
47
|
}
|
|
40
|
48
|
}
|
|
41
|
49
|
}
|
|
42
|
|
- Err(_) => {}
|
|
|
50
|
+ Err(_) => {
|
|
|
51
|
+ println!("Base is not integer.");
|
|
|
52
|
+ process::exit(1)
|
|
|
53
|
+ }
|
|
43
|
54
|
};
|
|
44
|
55
|
}
|
|
45
|
56
|
|