Skip to content

Commit

Permalink
rusk: Use ok_or in max_value overflow handling
Browse files Browse the repository at this point in the history
Co-authored-by: Mr. Seppia <[email protected]>
  • Loading branch information
xevisalle and herr-seppia authored Dec 17, 2024
1 parent 0fc5350 commit be5df99
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions rusk/src/lib/node/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,8 @@ impl VMExecution for Rusk {
.gas_limit()
.checked_mul(tx.gas_price())
.and_then(|v| v.checked_add(tx.value()))
.and_then(|v| v.checked_add(tx.deposit()));

let max_value = match max_value {
Some(x) => x,
_ => {
return Err(anyhow::anyhow!(
"Value spent will overflow"
))
}
};
.and_then(|v| v.checked_add(tx.deposit()))
.ok_or(anyhow::anyhow!("Value spent will overflow"))?;

if max_value > account_data.balance {
return Err(anyhow::anyhow!(
Expand Down

0 comments on commit be5df99

Please sign in to comment.