aboutsummaryrefslogtreecommitdiffstats
path: root/src/schema.rs
diff options
context:
space:
mode:
authorYigit Sever2021-04-12 05:32:53 +0300
committerYigit Sever2021-04-12 05:32:53 +0300
commite0fb91039f34204b2a5c588a95cb3f1789ad2fa7 (patch)
tree9c38670c348f04c57185639c541a1a93b8cfde2a /src/schema.rs
parent62aa261e1fd531afd1e5fa7244471d051a78db38 (diff)
downloadgradecoin-e0fb91039f34204b2a5c588a95cb3f1789ad2fa7.tar.gz
gradecoin-e0fb91039f34204b2a5c588a95cb3f1789ad2fa7.tar.bz2
gradecoin-e0fb91039f34204b2a5c588a95cb3f1789ad2fa7.zip
Implement proof-of-work
Using blacke2s: https://docs.rs/blake2/0.9.1/blake2/ Using this guy's hash checker https://gist.github.com/gkbrk/2e4835e3a17b3fb6e1e7 blacke2s with 5 bits 0 can mine a block between 20 seconds to 359 during my tests, hope it'll be fun
Diffstat (limited to 'src/schema.rs')
-rw-r--r--src/schema.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/schema.rs b/src/schema.rs
index 909b5cd..98291d7 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -62,17 +62,25 @@ pub struct Block {
62 // somewhere 62 // somewhere
63 // I want to keep this as a String vector because it makes things easier elsewhere 63 // I want to keep this as a String vector because it makes things easier elsewhere
64 pub transaction_list: Vec<String>, // hashes of the transactions (or just "source" for now) 64 pub transaction_list: Vec<String>, // hashes of the transactions (or just "source" for now)
65 pub nonce: String, 65 pub nonce: u32,
66 pub timestamp: NaiveDateTime, 66 pub timestamp: NaiveDateTime,
67 pub hash: String, // future proof'd baby 67 pub hash: String, // future proof'd baby
68} 68}
69 69
70/// For prototyping and letting serde handle everything json
71#[derive(Serialize, Deserialize, Debug)]
72pub struct NakedBlock {
73 pub transaction_list: Vec<String>,
74 pub nonce: u32,
75 pub timestamp: NaiveDateTime,
76}
77
70impl Block { 78impl Block {
71 /// Genesis block 79 /// Genesis block
72 pub fn new() -> Block { 80 pub fn new() -> Block {
73 Block { 81 Block {
74 transaction_list: vec![], 82 transaction_list: vec![],
75 nonce: String::from(""), 83 nonce: 0,
76 timestamp: NaiveDate::from_ymd(2021, 04, 11).and_hms(20, 45, 00), 84 timestamp: NaiveDate::from_ymd(2021, 04, 11).and_hms(20, 45, 00),
77 hash: String::from(""), 85 hash: String::from(""),
78 } 86 }