Skip to content

Commit

Permalink
Flatten if block in check_gas_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoopmann committed Nov 18, 2023
1 parent f58409d commit 76a7f23
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,19 @@ where
// limit as calculated with a desired limit of 0, and builders which fall
// back to calculating with the default 30_000_000.
// TODO: Review if we still need this
if registered_gas_limit != 0
|| block_gas_limit != calc_gas_limit(parent.gas_limit, 30_000_000)
if registered_gas_limit == 0
&& block_gas_limit == calc_gas_limit(parent.gas_limit, 30_000_000)
{
let calculated_gas_limit = calc_gas_limit(parent.gas_limit, registered_gas_limit);
if calculated_gas_limit != block_gas_limit {
return Err(internal_rpc_err(format!(
"Incorrect gas limit set, expected: {}, got: {}",
calculated_gas_limit, block_gas_limit
)));
}
return Ok(());
}
let calculated_gas_limit = calc_gas_limit(parent.gas_limit, registered_gas_limit);
if calculated_gas_limit == block_gas_limit {
return Ok(());
}
Ok(())
Err(internal_rpc_err(format!(
"Incorrect gas limit set, expected: {}, got: {}",
calculated_gas_limit, block_gas_limit
)))
}
}

Expand Down

0 comments on commit 76a7f23

Please sign in to comment.