Skip to content

Commit

Permalink
Merge pull request #102 from stellar/chore/clippy
Browse files Browse the repository at this point in the history
fix: clippy
  • Loading branch information
willemneal authored Jul 11, 2024
2 parents dbb390c + 2ff4f64 commit c8965d0
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions cmd/soroban-rpc/lib/preflight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@ impl CPreflightResult {
}

fn new_from_transaction_data(
transaction_data: &Option<SorobanTransactionData>,
restore_preamble: &Option<RestoreOpSimulationResult>,
transaction_data: Option<&SorobanTransactionData>,
restore_preamble: Option<&RestoreOpSimulationResult>,
error: String,
) -> Self {
let min_fee = transaction_data.as_ref().map_or(0, |d| d.resource_fee);
let min_fee = transaction_data.map_or(0, |d| d.resource_fee);
let mut result = Self {
error: string_to_c(error),
transaction_data: option_xdr_to_c(transaction_data.as_ref()),
transaction_data: option_xdr_to_c(transaction_data),
min_fee,
..Default::default()
};
Expand Down Expand Up @@ -361,10 +361,10 @@ fn preflight_extend_ttl_op(
Err(e) => (None, Err(e)),
};

let error_str = extract_error_string(&maybe_restore_result, go_storage.as_ref());
let error_str = extract_error_string(&maybe_restore_result, go_storage);
Ok(CPreflightResult::new_from_transaction_data(
&maybe_transaction_data,
&maybe_restore_result.unwrap_or(None),
maybe_transaction_data.as_ref(),
maybe_restore_result.ok().flatten().as_ref(),
error_str,
))
}
Expand All @@ -384,10 +384,8 @@ fn preflight_restore_op(
);
let error_str = extract_error_string(&simulation_result, go_storage.as_ref());
CPreflightResult::new_from_transaction_data(
&simulation_result
.map(|r| Some(r.transaction_data))
.unwrap_or(None),
&None,
simulation_result.ok().map(|r| r.transaction_data).as_ref(),
None,
error_str,
)
}
Expand Down Expand Up @@ -655,10 +653,9 @@ impl SnapshotSourceWithArchive for GoLedgerStorage {
fn extract_error_string<T>(simulation_result: &Result<T>, go_storage: &GoLedgerStorage) -> String {
match simulation_result {
Ok(_) => String::new(),
Err(e) =>
// Override any simulation result with a storage error (if any). Simulation does not propagate the storage
// errors, but these provide more exact information on the root cause.
{
Err(e) => {
// Override any simulation result with a storage error (if any). Simulation does not propagate the storage
// errors, but these provide more exact information on the root cause.
if let Some(e) = go_storage.internal_error.borrow().as_ref() {
format!("{e:?}")
} else {
Expand Down

0 comments on commit c8965d0

Please sign in to comment.