diff options
| author | Yigit Sever | 2021-04-14 21:28:37 +0300 |
|---|---|---|
| committer | Yigit Sever | 2021-04-14 21:28:37 +0300 |
| commit | 412116978169701479814d433a8bad73bfa54e02 (patch) | |
| tree | 343d506fa197b5e2e8f20e2b155e6956024aef83 /src/schema.rs | |
| parent | 58d64bcbbe1c0b698f2fb27ae5454a91aef79941 (diff) | |
| download | gradecoin-412116978169701479814d433a8bad73bfa54e02.tar.gz gradecoin-412116978169701479814d433a8bad73bfa54e02.tar.bz2 gradecoin-412116978169701479814d433a8bad73bfa54e02.zip | |
Accepted block transactions play out now
Diffstat (limited to 'src/schema.rs')
| -rw-r--r-- | src/schema.rs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/schema.rs b/src/schema.rs index 6402724..2a9e1db 100644 --- a/src/schema.rs +++ b/src/schema.rs | |||
| @@ -37,7 +37,7 @@ fn last_block_exists() -> (bool, String) { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | fn read_block_name() -> io::Result<Vec<PathBuf>> { | 39 | fn read_block_name() -> io::Result<Vec<PathBuf>> { |
| 40 | let mut entries = fs::read_dir("./blocks")? | 40 | let entries = fs::read_dir("./blocks")? |
| 41 | .map(|res| res.map(|e| e.path())) | 41 | .map(|res| res.map(|e| e.path())) |
| 42 | .collect::<Result<Vec<_>, io::Error>>()?; | 42 | .collect::<Result<Vec<_>, io::Error>>()?; |
| 43 | 43 | ||
| @@ -89,13 +89,10 @@ pub struct Claims { | |||
| 89 | /// | 89 | /// |
| 90 | /// [`Db::users`] is the in memory representation of the users, with their public keys, metu_ids and | 90 | /// [`Db::users`] is the in memory representation of the users, with their public keys, metu_ids and |
| 91 | /// gradecoin balances. | 91 | /// gradecoin balances. |
| 92 | /// | ||
| 93 | /// TODO: Replace the pending_transactions HashMap<String, Transaction> with | ||
| 94 | /// HashMap<Fingerprint, Transaction> | ||
| 95 | #[derive(Debug, Clone)] | 92 | #[derive(Debug, Clone)] |
| 96 | pub struct Db { | 93 | pub struct Db { |
| 97 | pub blockchain: Arc<RwLock<Block>>, | 94 | pub blockchain: Arc<RwLock<Block>>, |
| 98 | pub pending_transactions: Arc<RwLock<HashMap<String, Transaction>>>, | 95 | pub pending_transactions: Arc<RwLock<HashMap<Fingerprint, Transaction>>>, |
| 99 | pub users: Arc<RwLock<HashMap<String, User>>>, | 96 | pub users: Arc<RwLock<HashMap<String, User>>>, |
| 100 | } | 97 | } |
| 101 | 98 | ||
| @@ -166,7 +163,7 @@ pub struct User { | |||
| 166 | pub balance: i32, | 163 | pub balance: i32, |
| 167 | } | 164 | } |
| 168 | 165 | ||
| 169 | /// The values will be hard coded so MetuId::new() can accept/reject values based on that | 166 | /// The values are hard coded in [`OUR_STUDENTS`] so MetuId::new() can accept/reject values based on that |
| 170 | #[derive(Serialize, Deserialize, Debug, PartialEq)] | 167 | #[derive(Serialize, Deserialize, Debug, PartialEq)] |
| 171 | pub struct MetuId { | 168 | pub struct MetuId { |
| 172 | id: String, | 169 | id: String, |
