|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+extern crate clap;
|
|
|
2
|
+extern crate time;
|
|
|
3
|
+use clap::{Arg, App, SubCommand};
|
|
|
4
|
+mod hasher_sha256;
|
|
|
5
|
+mod hash256;
|
|
|
6
|
+
|
|
|
7
|
+pub fn main(/*base: usize, */number: usize, diff: String) {
|
|
|
8
|
+ let matches = create_app().get_matches();
|
|
|
9
|
+ let base;
|
|
|
10
|
+ match matches.value_of("base") {
|
|
|
11
|
+ Some(x) => {base = u64::from(x)}
|
|
|
12
|
+ None => {panic!()}
|
|
|
13
|
+ };
|
|
|
14
|
+ match hash256::verify_product(base, number, diff) {
|
|
|
15
|
+ Some(x) => { println!("{}", diff); }
|
|
|
16
|
+ None => { println!("None"); }
|
|
|
17
|
+ }
|
|
|
18
|
+}
|
|
|
19
|
+
|
|
|
20
|
+fn create_app<'a, 'b>() -> App<'a, 'b> {
|
|
|
21
|
+ App::new("Hash256")
|
|
|
22
|
+ .version("1.0")
|
|
|
23
|
+ .author("Lorenz Bung & Joshua Rutschmann")
|
|
|
24
|
+ .about("Calculates the Hashvalue of the given base, number and difficulty.")
|
|
|
25
|
+ .arg(Arg::with_name("base")
|
|
|
26
|
+ .short("b")
|
|
|
27
|
+ .long("base")
|
|
|
28
|
+ .value_name("VALUE")
|
|
|
29
|
+ .help("The base of the hash to be calculated on.")
|
|
|
30
|
+ .takes_value(true)
|
|
|
31
|
+ .required(true))
|
|
|
32
|
+ .arg(Arg::with_name("number")
|
|
|
33
|
+ .short("n")
|
|
|
34
|
+ .long("number")
|
|
|
35
|
+ .value_name("VALUE")
|
|
|
36
|
+ .help("The number of the hash to be calculated on.")
|
|
|
37
|
+ .takes_value(true)
|
|
|
38
|
+ .required(true))
|
|
|
39
|
+ .arg(Arg::with_name("difficulty")
|
|
|
40
|
+ .short("d")
|
|
|
41
|
+ .long("difficulty")
|
|
|
42
|
+ .value_name("VALUE")
|
|
|
43
|
+ .help("The difficulty of the calculated hash.")
|
|
|
44
|
+ .takes_value(true)
|
|
|
45
|
+ .required(true))
|
|
|
46
|
+ .subcommand(SubCommand::with_name("timings")
|
|
|
47
|
+ .about("controls timing features")
|
|
|
48
|
+ .version("1.0")
|
|
|
49
|
+ .author("Lorenz Bung & Joshua Rutschmann"))
|
|
|
50
|
+}
|