Skip to content

Commit

Permalink
Fix error handling for the total requested amount
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Lelek authored and kacperzuk-neti committed May 21, 2024
1 parent cf07fda commit 90a9e76
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fplus-lib/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3559,9 +3559,11 @@ _The initial issue can be edited in order to solve the request of the verifier.
let total_requested = parse_size_to_bytes(&application_file.datacap.total_requested_amount).ok_or(
LDNError::Load("Can not parse total requested amount to bytes".into()),
)?;

if requested_so_far >= total_requested {
return Err(LDNError::Load("Total datacap reached".into()));
let ssa_amount = parse_size_to_bytes((format!("{}{}", &info.amount, &info.amount_type)).as_str()).ok_or(
LDNError::Load("Can not parse requested amount to bytes".into()),
)?;
if requested_so_far + ssa_amount > total_requested {
return Err(LDNError::Load("The sum of datacap requested so far and requested amount exceeds total requested amount".into()));
}
let refill_info = RefillInfo {
id: info.id,
Expand Down

0 comments on commit 90a9e76

Please sign in to comment.