diff options
author | Yigit Sever | 2021-04-14 22:40:33 +0300 |
---|---|---|
committer | Yigit Sever | 2021-04-14 22:40:33 +0300 |
commit | 21e62ad7e312bbe57bf7098f0b3607e72fcffddb (patch) | |
tree | caba4d95573cd27698878790a1e4683e2ab24082 /src/handlers.rs | |
parent | 271ac922b8e47a74fc467c2a4c54beae7a4fe60d (diff) | |
download | gradecoin-21e62ad7e312bbe57bf7098f0b3607e72fcffddb.tar.gz gradecoin-21e62ad7e312bbe57bf7098f0b3607e72fcffddb.tar.bz2 gradecoin-21e62ad7e312bbe57bf7098f0b3607e72fcffddb.zip |
Transactions return as dict
Diffstat (limited to 'src/handlers.rs')
-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)) |