ledger: confirm_slot_entries(): Refactor: reduce indent (#30785)
No functional changes. Use early return pattern, to reduce indentation in the most important part of the confirmation logic.
This commit is contained in:
parent
d3273ba118
commit
ea7c72f7a8
|
@ -928,9 +928,9 @@ impl ConfirmationTiming {
|
|||
execute_batches_internal_metrics: ExecuteBatchesInternalMetrics,
|
||||
) {
|
||||
let ConfirmationTiming {
|
||||
execute_timings: ref mut cumulative_execute_timings,
|
||||
execute_batches_us: ref mut cumulative_execute_batches_us,
|
||||
ref mut end_to_end_execute_timings,
|
||||
execute_timings: cumulative_execute_timings,
|
||||
execute_batches_us: cumulative_execute_batches_us,
|
||||
end_to_end_execute_timings,
|
||||
..
|
||||
} = self;
|
||||
|
||||
|
@ -1094,7 +1094,8 @@ fn confirm_slot_entries(
|
|||
let tick_hash_count = &mut progress.tick_hash_count;
|
||||
verify_ticks(bank, &entries, slot_full, tick_hash_count).map_err(|err| {
|
||||
warn!(
|
||||
"{:#?}, slot: {}, entry len: {}, tick_height: {}, last entry: {}, last_blockhash: {}, shred_index: {}, slot_full: {}",
|
||||
"{:#?}, slot: {}, entry len: {}, tick_height: {}, last entry: {}, \
|
||||
last_blockhash: {}, shred_index: {}, slot_full: {}",
|
||||
err,
|
||||
slot,
|
||||
num_entries,
|
||||
|
@ -1139,8 +1140,14 @@ fn confirm_slot_entries(
|
|||
);
|
||||
let transaction_cpu_duration_us = timing::duration_as_us(&check_start.elapsed());
|
||||
|
||||
match check_result {
|
||||
Ok(mut check_result) => {
|
||||
let mut check_result = match check_result {
|
||||
Ok(check_result) => check_result,
|
||||
Err(err) => {
|
||||
warn!("Ledger proof of history failed at slot: {}", bank.slot());
|
||||
return Err(err.into());
|
||||
}
|
||||
};
|
||||
|
||||
let entries = check_result.entries();
|
||||
assert!(entries.is_some());
|
||||
|
||||
|
@ -1169,11 +1176,10 @@ fn confirm_slot_entries(
|
|||
replay_elapsed.stop();
|
||||
timing.replay_elapsed += replay_elapsed.as_us();
|
||||
|
||||
// If running signature verification on the GPU, wait for that
|
||||
// computation to finish, and get the result of it. If we did the
|
||||
// signature verification on the CPU, this just returns the
|
||||
// already-computed result produced in start_verify_transactions.
|
||||
// Either way, check the result of the signature verification.
|
||||
// If running signature verification on the GPU, wait for that computation to finish, and get
|
||||
// the result of it. If we did the signature verification on the CPU, this just returns the
|
||||
// already-computed result produced in start_verify_transactions. Either way, check the result
|
||||
// of the signature verification.
|
||||
if !check_result.finish_verify() {
|
||||
warn!("Ledger proof of history failed at slot: {}", bank.slot());
|
||||
return Err(TransactionError::SignatureFailure.into());
|
||||
|
@ -1182,8 +1188,8 @@ fn confirm_slot_entries(
|
|||
if let Some(mut verifier) = verifier {
|
||||
let verified = verifier.finish_verify();
|
||||
timing.poh_verify_elapsed += verifier.poh_duration_us();
|
||||
// The GPU Entry verification (if any) is kicked off right when the CPU-side
|
||||
// Entry verification finishes, so these times should be disjoint
|
||||
// The GPU Entry verification (if any) is kicked off right when the CPU-side Entry
|
||||
// verification finishes, so these times should be disjoint
|
||||
timing.transaction_verify_elapsed +=
|
||||
transaction_cpu_duration_us + check_result.gpu_verify_duration();
|
||||
if !verified {
|
||||
|
@ -1203,12 +1209,6 @@ fn confirm_slot_entries(
|
|||
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("Ledger proof of history failed at slot: {}", bank.slot());
|
||||
Err(err.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Special handling required for processing the entries in slot 0
|
||||
fn process_bank_0(
|
||||
|
|
Loading…
Reference in New Issue