diff options
Diffstat (limited to 'src/schema.rs')
-rw-r--r-- | src/schema.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/schema.rs b/src/schema.rs index 556e625..c4917ab 100644 --- a/src/schema.rs +++ b/src/schema.rs | |||
@@ -29,6 +29,8 @@ pub struct Db { | |||
29 | pub blockchain: Arc<RwLock<Vec<Block>>>, | 29 | pub blockchain: Arc<RwLock<Vec<Block>>>, |
30 | // every proposer can have _one_ pending transaction, a way to enforce this, String is proposer identifier | 30 | // every proposer can have _one_ pending transaction, a way to enforce this, String is proposer identifier |
31 | pub pending_transactions: Arc<RwLock<HashMap<String, Transaction>>>, | 31 | pub pending_transactions: Arc<RwLock<HashMap<String, Transaction>>>, |
32 | // this was bound to happen eventually | ||
33 | pub users: Arc<RwLock<HashMap<String, User>>>, | ||
32 | } | 34 | } |
33 | 35 | ||
34 | impl Db { | 36 | impl Db { |
@@ -36,12 +38,15 @@ impl Db { | |||
36 | Db { | 38 | Db { |
37 | blockchain: Arc::new(RwLock::new(Vec::new())), | 39 | blockchain: Arc::new(RwLock::new(Vec::new())), |
38 | pending_transactions: Arc::new(RwLock::new(HashMap::new())), | 40 | pending_transactions: Arc::new(RwLock::new(HashMap::new())), |
41 | users: Arc::new(RwLock::new(HashMap::new())), | ||
39 | } | 42 | } |
40 | } | 43 | } |
41 | } | 44 | } |
42 | 45 | ||
43 | /// A transaction between `source` and `target` that moves `amount` | 46 | /// A transaction between `source` and `target` that moves `amount` Note: |
44 | #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] | 47 | /// https://serde.rs/container-attrs.html might be valueable to normalize the serialize/deserialize |
48 | /// conventions as these will be hashed | ||
49 | #[derive(Serialize, Deserialize, Debug)] | ||
45 | pub struct Transaction { | 50 | pub struct Transaction { |
46 | pub source: String, | 51 | pub source: String, |
47 | pub target: String, | 52 | pub target: String, |
@@ -65,5 +70,10 @@ pub struct Block { | |||
65 | pub hash: String, // future proof'd baby | 70 | pub hash: String, // future proof'd baby |
66 | } | 71 | } |
67 | 72 | ||
73 | #[derive(Serialize, Deserialize, Debug)] | ||
74 | pub struct User { | ||
75 | username: String, | ||
76 | token: String | ||
77 | } | ||
68 | 78 | ||
69 | // TODO: write schema tests using the original repo <09-04-21, yigit> // | 79 | // TODO: write schema tests using the original repo <09-04-21, yigit> // |