aboutsummaryrefslogtreecommitdiffstats
path: root/src/schema.rs
diff options
context:
space:
mode:
authoralpaylan2021-04-12 22:15:17 +0300
committeralpaylan2021-04-12 22:15:17 +0300
commitaa169ad1b3c277859f01413a945ea2d6f1375615 (patch)
tree402042bce17641759fa28e5c9a7219025caefcbb /src/schema.rs
parent87e690420cb61efc172e82a29c38b479fc734247 (diff)
downloadgradecoin-aa169ad1b3c277859f01413a945ea2d6f1375615.tar.gz
gradecoin-aa169ad1b3c277859f01413a945ea2d6f1375615.tar.bz2
gradecoin-aa169ad1b3c277859f01413a945ea2d6f1375615.zip
implement user authentication using jwt
Diffstat (limited to 'src/schema.rs')
-rw-r--r--src/schema.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/schema.rs b/src/schema.rs
index 98291d7..39921b8 100644
--- a/src/schema.rs
+++ b/src/schema.rs
@@ -41,18 +41,20 @@ impl Db {
41 } 41 }
42} 42}
43 43
44pub type PublicKeySignature = String;
45
44/// A transaction between `source` and `target` that moves `amount` 46/// A transaction between `source` and `target` that moves `amount`
45#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] 47#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
46pub struct Transaction { 48pub struct Transaction {
47 // TODO: new field by <11-04-21, yigit> // 49 pub by: PublicKeySignature,
48 pub source: String, 50 pub source: PublicKeySignature,
49 pub target: String, 51 pub target: PublicKeySignature,
50 pub amount: i32, 52 pub amount: i32,
51 pub timestamp: NaiveDateTime, 53 pub timestamp: NaiveDateTime,
52} 54}
53 55
54/// A block that was proposed with `transaction_list` and `nonce` that made `hash` valid 56/// A block that was proposed with `transaction_list` and `nonce` that made `hash` valid
55/// https://serde.rs/container-attrs.html might be valueable to normalize the serialize/deserialize 57/// https://serde.rs/container-attrs.html might be valuable to normalize the serialize/deserialize
56/// conventions as these will be hashed 58/// conventions as these will be hashed
57#[derive(Serialize, Deserialize, Debug)] 59#[derive(Serialize, Deserialize, Debug)]
58pub struct Block { 60pub struct Block {
@@ -61,7 +63,7 @@ pub struct Block {
61 // we can leave this as is and whenever we have a new block we _could_ just log it to file 63 // we can leave this as is and whenever we have a new block we _could_ just log it to file
62 // somewhere 64 // somewhere
63 // I want to keep this as a String vector because it makes things easier elsewhere 65 // 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) 66 pub transaction_list: Vec<PublicKeySignature>, // hashes of the transactions (or just "source" for now)
65 pub nonce: u32, 67 pub nonce: u32,
66 pub timestamp: NaiveDateTime, 68 pub timestamp: NaiveDateTime,
67 pub hash: String, // future proof'd baby 69 pub hash: String, // future proof'd baby
@@ -70,7 +72,7 @@ pub struct Block {
70/// For prototyping and letting serde handle everything json 72/// For prototyping and letting serde handle everything json
71#[derive(Serialize, Deserialize, Debug)] 73#[derive(Serialize, Deserialize, Debug)]
72pub struct NakedBlock { 74pub struct NakedBlock {
73 pub transaction_list: Vec<String>, 75 pub transaction_list: Vec<PublicKeySignature>,
74 pub nonce: u32, 76 pub nonce: u32,
75 pub timestamp: NaiveDateTime, 77 pub timestamp: NaiveDateTime,
76} 78}