diff options
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)) |