aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYigit Sever2021-04-27 01:49:23 +0300
committerYigit Sever2021-04-27 01:49:23 +0300
commit154f6b5f912308723c27ef85187920396ced647f (patch)
tree9f45bd673b2ceb4eb23bf622cff2b270a65ef53b /src
parent19f52705f18ad2a72e999e5038f30b479ca90035 (diff)
downloadgradecoin-154f6b5f912308723c27ef85187920396ced647f.tar.gz
gradecoin-154f6b5f912308723c27ef85187920396ced647f.tar.bz2
gradecoin-154f6b5f912308723c27ef85187920396ced647f.zip
No empty txs anymore
Diffstat (limited to 'src')
-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 ));