Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clippy #102

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading