From 96d34952c1fb2cf096b6c907feada60b0db27a8f Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Sat, 16 Apr 2022 17:36:07 +0300 Subject: remove examples --- examples/mining.rs | 66 ---------------------------------------------------- examples/serdeser.rs | 16 ------------- 2 files changed, 82 deletions(-) delete mode 100644 examples/mining.rs delete mode 100644 examples/serdeser.rs (limited to 'examples') diff --git a/examples/mining.rs b/examples/mining.rs deleted file mode 100644 index e3d1487..0000000 --- a/examples/mining.rs +++ /dev/null @@ -1,66 +0,0 @@ -use chrono::NaiveDate; -use gradecoin::schema::NakedBlock; -use serde_json; -use std::sync::{Arc, Mutex}; -use std::thread; -use std::time::Instant; - -use blake2::{Blake2s, Digest}; - -const N: usize = 4; - -pub fn main() { - let counter = Arc::new(Mutex::new(0)); - - let now = Instant::now(); - - let mut threads = Vec::with_capacity(N); - - (0..N).for_each(|_| { - let counter = Arc::clone(&counter); - threads.push(thread::spawn(move || { - let mut b = NakedBlock { - transaction_list: vec!["fingerprint_of_some_guy".to_owned()], - nonce: 0, - timestamp: NaiveDate::from_ymd(2021, 04, 13).and_hms(23, 38, 00), - }; - - let start: u32; - let end: u32; - { - let mut num = counter.lock().unwrap(); - - println!("Starting with 2 over {}", num); - - start = 0 + (1073741824 * *num); - end = 1073741820 * (*num + 1); - *num += 1; - } - - println!("here {} - {}", start, end); - - for nonce in start..end { - b.nonce = nonce; - - let j = serde_json::to_vec(&b).unwrap(); - - let result = Blake2s::digest(&j); - - let first_six = result[0] as i32 + result[1] as i32 + (result[2]) as i32; - - if first_six == 0 { - println!("{} - {:x}\n{:?}", nonce, result, b); - break; - } - } - })); - }); - - threads.into_iter().for_each(|thread| { - thread - .join() - .expect("The thread creating or execution failed !") - }); - - println!("it took {} seconds", now.elapsed().as_secs()); -} diff --git a/examples/serdeser.rs b/examples/serdeser.rs deleted file mode 100644 index 4fdfdc2..0000000 --- a/examples/serdeser.rs +++ /dev/null @@ -1,16 +0,0 @@ -use gradecoin::schema::Transaction; -use serde_json; - -pub fn main() { - - let tx = Transaction { - source: "fingerprint_of_some_guy".to_owned(), - target: "31415926535897932384626433832795028841971693993751058209749445923".to_owned(), - amount: 2, - timestamp: chrono::NaiveDate::from_ymd(2021, 04, 13).and_hms(20, 55, 30), - }; - - let tx_string = serde_json::to_string(&tx).unwrap(); - - println!("{}", &tx_string); -} -- cgit v1.2.3-70-g09d2