aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralpaylan2021-04-12 19:59:52 +0300
committeralpaylan2021-04-12 19:59:52 +0300
commitdf484d87424674b88ccfa9392cfa9a75cc4abe48 (patch)
treed0f65d9aff8967a3b99d6f828c32366b94e64758
parent8e3d17476566565449cfc952f28c5740e474e94f (diff)
downloadgradecoin-df484d87424674b88ccfa9392cfa9a75cc4abe48.tar.gz
gradecoin-df484d87424674b88ccfa9392cfa9a75cc4abe48.tar.bz2
gradecoin-df484d87424674b88ccfa9392cfa9a75cc4abe48.zip
six rightmost zeros for mining
-rw-r--r--examples/mining.rs4
-rw-r--r--src/handlers.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/examples/mining.rs b/examples/mining.rs
index 56e33f3..c95c214 100644
--- a/examples/mining.rs
+++ b/examples/mining.rs
@@ -23,9 +23,9 @@ pub fn main() {
23 23
24 let result = Blake2s::digest(&j); 24 let result = Blake2s::digest(&j);
25 25
26 let first_five = result[31] as i32 + result[30] as i32 + (result[29] << 4) as i32; 26 let first_six = result[31] as i32 + result[30] as i32 + result[29] as i32;
27 27
28 if first_five == 0 { 28 if first_six == 0 {
29 println!("{} - {:x}\n{:?}", nonce, result, b); 29 println!("{} - {:x}\n{:?}", nonce, result, b);
30 break; 30 break;
31 } 31 }
diff --git a/src/handlers.rs b/src/handlers.rs
index 6edc96f..38bd459 100644
--- a/src/handlers.rs
+++ b/src/handlers.rs
@@ -137,8 +137,8 @@ pub async fn propose_block(new_block: Block, db: Db) -> Result<impl warp::Reply,
137 let hashvalue = Blake2s::digest(&naked_block_flat); 137 let hashvalue = Blake2s::digest(&naked_block_flat);
138 let hash_string = format!("{:x}", hashvalue); 138 let hash_string = format!("{:x}", hashvalue);
139 139
140 // 5 rightmost bits are zero 140 // 6 rightmost bits are zero
141 let should_zero = hashvalue[31] as i32 + hashvalue[30] as i32 + (hashvalue[29] << 4) as i32; 141 let should_zero = hashvalue[31] as i32 + hashvalue[30] as i32 + hashvalue[29] as i32;
142 142
143 if should_zero == 0 { 143 if should_zero == 0 {
144 // one last check to see if block is telling the truth 144 // one last check to see if block is telling the truth