From 154f6b5f912308723c27ef85187920396ced647f Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Tue, 27 Apr 2021 01:49:23 +0300 Subject: No empty txs anymore --- src/handlers.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/handlers.rs b/src/handlers.rs index 2dcdafb..09ce4a5 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -29,6 +29,7 @@ const REGISTER_BONUS: u16 = 40; const BLOCK_REWARD: u16 = 3; // Transaction amount limit const TX_UPPER_LIMIT: u16 = 2; +const TX_LOWER_LIMIT: u16 = 1; // Transaction traffic reward const TX_TRAFFIC_REWARD: u16 = 1; @@ -755,15 +756,18 @@ pub async fn propose_transaction( } // Is transaction amount within bounds - if new_transaction.amount > TX_UPPER_LIMIT { + if new_transaction.amount > TX_UPPER_LIMIT || new_transaction.amount < TX_LOWER_LIMIT { debug!( - "Transaction amount cannot exceed {}, was {}", - TX_UPPER_LIMIT, new_transaction.amount + "Transaction amount is not between {} and {}, was {}", + TX_LOWER_LIMIT, TX_UPPER_LIMIT, new_transaction.amount ); return Ok(warp::reply::with_status( warp::reply::json(&GradeCoinResponse { res: ResponseType::Error, - message: format!("Transaction amount cannot exceed {}", TX_UPPER_LIMIT), + message: format!( + "Transaction amount should be between {} and {}", + TX_LOWER_LIMIT, TX_UPPER_LIMIT + ), }), StatusCode::BAD_REQUEST, )); -- cgit v1.2.3-70-g09d2