From be5df996bc4c74b4089ec803142e5465f9fb8924 Mon Sep 17 00:00:00 2001 From: xevisalle <38231508+xevisalle@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:05:32 +0100 Subject: [PATCH] rusk: Use ok_or in max_value overflow handling Co-authored-by: Mr. Seppia --- rusk/src/lib/node/vm.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/rusk/src/lib/node/vm.rs b/rusk/src/lib/node/vm.rs index 6d3d25cc5..fdcff50b5 100644 --- a/rusk/src/lib/node/vm.rs +++ b/rusk/src/lib/node/vm.rs @@ -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!(