aboutsummaryrefslogtreecommitdiffstats
path: root/src/handlers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/handlers.rs')
-rw-r--r--src/handlers.rs12
1 files changed, 8 insertions, 4 deletions
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;
29const BLOCK_REWARD: u16 = 3; 29const BLOCK_REWARD: u16 = 3;
30// Transaction amount limit 30// Transaction amount limit
31const TX_UPPER_LIMIT: u16 = 2; 31const TX_UPPER_LIMIT: u16 = 2;
32const TX_LOWER_LIMIT: u16 = 1;
32// Transaction traffic reward 33// Transaction traffic reward
33const TX_TRAFFIC_REWARD: u16 = 1; 34const TX_TRAFFIC_REWARD: u16 = 1;
34 35
@@ -755,15 +756,18 @@ pub async fn propose_transaction(
755 } 756 }
756 757
757 // Is transaction amount within bounds 758 // Is transaction amount within bounds
758 if new_transaction.amount > TX_UPPER_LIMIT { 759 if new_transaction.amount > TX_UPPER_LIMIT || new_transaction.amount < TX_LOWER_LIMIT {
759 debug!( 760 debug!(
760 "Transaction amount cannot exceed {}, was {}", 761 "Transaction amount is not between {} and {}, was {}",
761 TX_UPPER_LIMIT, new_transaction.amount 762 TX_LOWER_LIMIT, TX_UPPER_LIMIT, new_transaction.amount
762 ); 763 );
763 return Ok(warp::reply::with_status( 764 return Ok(warp::reply::with_status(
764 warp::reply::json(&GradeCoinResponse { 765 warp::reply::json(&GradeCoinResponse {
765 res: ResponseType::Error, 766 res: ResponseType::Error,
766 message: format!("Transaction amount cannot exceed {}", TX_UPPER_LIMIT), 767 message: format!(
768 "Transaction amount should be between {} and {}",
769 TX_LOWER_LIMIT, TX_UPPER_LIMIT
770 ),
767 }), 771 }),
768 StatusCode::BAD_REQUEST, 772 StatusCode::BAD_REQUEST,
769 )); 773 ));