Skip to content

Commit

Permalink
fix vec capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvsadana committed Oct 8, 2024
1 parent 820ed38 commit 2345daa
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions crates/client/rpc/src/versions/v0_7_1/methods/read/estimate_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ pub async fn estimate_fee(

let execution_results = exec_context.re_execute_transactions([], transactions, true, validate)?;

let fee_estimates = execution_results.iter().enumerate().try_fold(Vec::new(), |mut acc, (index, result)| {
if result.execution_info.is_reverted() {
return Err(StarknetRpcApiError::TxnExecutionError {
tx_index: index,
error: result.execution_info.revert_error.clone().unwrap_or_default(),
});
}
acc.push(exec_context.execution_result_to_fee_estimate(result));
Ok(acc)
})?;
let fee_estimates = execution_results.iter().enumerate().try_fold(
Vec::with_capacity(execution_results.len()),
|mut acc, (index, result)| {
if result.execution_info.is_reverted() {
return Err(StarknetRpcApiError::TxnExecutionError {
tx_index: index,
error: result.execution_info.revert_error.clone().unwrap_or_default(),
});
}
acc.push(exec_context.execution_result_to_fee_estimate(result));
Ok(acc)
},
)?;

Ok(fee_estimates)
}

0 comments on commit 2345daa

Please sign in to comment.