diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index 6305560..bf554ab 100644 --- a/src/handlers.rs +++ b/src/handlers.rs | |||
@@ -18,7 +18,7 @@ use std::fs; | |||
18 | use warp::{http::StatusCode, reply}; | 18 | use warp::{http::StatusCode, reply}; |
19 | 19 | ||
20 | use crate::PRIVATE_KEY; | 20 | use crate::PRIVATE_KEY; |
21 | const BLOCK_TRANSACTION_COUNT: u8 = 5; | 21 | const BLOCK_TRANSACTION_COUNT: u8 = 1; |
22 | const BLOCK_REWARD: u16 = 3; | 22 | const BLOCK_REWARD: u16 = 3; |
23 | const TX_UPPER_LIMIT: u16 = 2; | 23 | const TX_UPPER_LIMIT: u16 = 2; |
24 | 24 | ||
@@ -181,7 +181,7 @@ pub async fn authenticate_user( | |||
181 | let auth_plaintext = match cipher.decrypt(&mut buf) { | 181 | let auth_plaintext = match cipher.decrypt(&mut buf) { |
182 | Ok(p) => p, | 182 | Ok(p) => p, |
183 | Err(err) => { | 183 | Err(err) => { |
184 | println!( | 184 | debug!( |
185 | "Base64 decoded auth request did not decrypt correctly {:?} {}", | 185 | "Base64 decoded auth request did not decrypt correctly {:?} {}", |
186 | &auth_packet, err | 186 | &auth_packet, err |
187 | ); | 187 | ); |
@@ -342,11 +342,12 @@ pub async fn propose_block( | |||
342 | 342 | ||
343 | warn!("New block proposal: {:?}", &new_block); | 343 | warn!("New block proposal: {:?}", &new_block); |
344 | 344 | ||
345 | if new_block.transaction_list.len() != BLOCK_TRANSACTION_COUNT as usize { | 345 | if new_block.transaction_list.len() < BLOCK_TRANSACTION_COUNT as usize { |
346 | debug!("{} transactions offered, needed {}", new_block.transaction_list.len(), BLOCK_TRANSACTION_COUNT); | ||
346 | let res_json = warp::reply::json(&GradeCoinResponse { | 347 | let res_json = warp::reply::json(&GradeCoinResponse { |
347 | res: ResponseType::Error, | 348 | res: ResponseType::Error, |
348 | message: format!( | 349 | message: format!( |
349 | "There should be {} transactions in the block", | 350 | "There should be at least {} transaction in the block", |
350 | BLOCK_TRANSACTION_COUNT | 351 | BLOCK_TRANSACTION_COUNT |
351 | ), | 352 | ), |
352 | }); | 353 | }); |
@@ -411,11 +412,11 @@ pub async fn propose_block( | |||
411 | proposed_transactions.insert(tx); | 412 | proposed_transactions.insert(tx); |
412 | } | 413 | } |
413 | 414 | ||
414 | if proposed_transactions.len() != BLOCK_TRANSACTION_COUNT as usize { | 415 | if proposed_transactions.len() < BLOCK_TRANSACTION_COUNT as usize { |
415 | let res_json = warp::reply::json(&GradeCoinResponse { | 416 | let res_json = warp::reply::json(&GradeCoinResponse { |
416 | res: ResponseType::Error, | 417 | res: ResponseType::Error, |
417 | message: format!( | 418 | message: format!( |
418 | "Block cannot contain less than {} unique transactions.", | 419 | "Block cannot contain less than {} unique transaction(s).", |
419 | BLOCK_TRANSACTION_COUNT | 420 | BLOCK_TRANSACTION_COUNT |
420 | ), | 421 | ), |
421 | }); | 422 | }); |