Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 356c6a3

Browse files
v1.18: Remove unnecessary unwrap from simulate_transaction_unchecked() (backport of #35375) (#35397)
Remove unnecessary unwrap from `simulate_transaction_unchecked()` (#35375) Remove unnecessary unwrap from simulate_transaction_unchecked() (cherry picked from commit cb260f1) Co-authored-by: Pankaj Garg <[email protected]>
1 parent 994e81e commit 356c6a3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

runtime/src/bank.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4295,9 +4295,7 @@ impl Bank {
42954295
let post_simulation_accounts = loaded_transactions
42964296
.into_iter()
42974297
.next()
4298-
.unwrap()
4299-
.0
4300-
.ok()
4298+
.and_then(|(loaded_transactions_res, _)| loaded_transactions_res.ok())
43014299
.map(|loaded_transaction| {
43024300
loaded_transaction
43034301
.accounts
@@ -4319,7 +4317,12 @@ impl Bank {
43194317

43204318
debug!("simulate_transaction: {:?}", timings);
43214319

4322-
let execution_result = execution_results.pop().unwrap();
4320+
let execution_result =
4321+
execution_results
4322+
.pop()
4323+
.unwrap_or(TransactionExecutionResult::NotExecuted(
4324+
TransactionError::InvalidProgramForExecution,
4325+
));
43234326
let flattened_result = execution_result.flattened_result();
43244327
let (logs, return_data, inner_instructions) = match execution_result {
43254328
TransactionExecutionResult::Executed { details, .. } => (

0 commit comments

Comments
 (0)