diff options
author | Yigit Sever | 2021-04-14 22:40:33 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-14 22:40:33 +0300 |
commit | 3f649d6233b06589480713f507924286d297e120 (patch) | |
tree | 6f7660e164a57da58f7708830de1ae5082ad975f /src | |
parent | 0599e005daa03e1cf4dc8e238c1c803c1970beb2 (diff) | |
download | gradecoin-3f649d6233b06589480713f507924286d297e120.tar.gz gradecoin-3f649d6233b06589480713f507924286d297e120.tar.bz2 gradecoin-3f649d6233b06589480713f507924286d297e120.zip |
Transactions return as dict
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index 0dfea15..90cc8c4 100644 --- a/src/handlers.rs +++ b/src/handlers.rs | |||
@@ -13,6 +13,7 @@ use rsa::{PaddingScheme, RSAPrivateKey}; | |||
13 | use serde::Serialize; | 13 | use serde::Serialize; |
14 | use serde_json; | 14 | use serde_json; |
15 | use sha2::Sha256; | 15 | use sha2::Sha256; |
16 | use std::collections::HashMap; | ||
16 | use std::convert::Infallible; | 17 | use std::convert::Infallible; |
17 | use std::fs; | 18 | use std::fs; |
18 | use warp::{http::StatusCode, reply}; | 19 | use warp::{http::StatusCode, reply}; |
@@ -208,13 +209,13 @@ pub async fn authenticate_user( | |||
208 | /// Cannot fail | 209 | /// Cannot fail |
209 | pub async fn list_transactions(db: Db) -> Result<impl warp::Reply, Infallible> { | 210 | pub async fn list_transactions(db: Db) -> Result<impl warp::Reply, Infallible> { |
210 | debug!("GET request to /transaction, list_transactions"); | 211 | debug!("GET request to /transaction, list_transactions"); |
211 | let mut result = Vec::new(); | 212 | let mut result = HashMap::new(); |
212 | 213 | ||
213 | let transactions = db.pending_transactions.read(); | 214 | let transactions = db.pending_transactions.read(); |
214 | // let transactions = transactions.clone().into_iter().collect(); | 215 | // let transactions = transactions.clone().into_iter().collect(); |
215 | 216 | ||
216 | for (_, value) in transactions.iter() { | 217 | for (fp, tx) in transactions.iter() { |
217 | result.push(value) | 218 | result.insert(fp, tx); |
218 | } | 219 | } |
219 | 220 | ||
220 | Ok(reply::with_status(reply::json(&result), StatusCode::OK)) | 221 | Ok(reply::with_status(reply::json(&result), StatusCode::OK)) |