separate check_transaction_age from check_age (#30994)

This commit is contained in:
Andrew Fitzgerald 2023-04-07 09:04:03 -07:00 committed by GitHub
parent 03abaf76d0
commit 15011eaa5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 13 deletions

View File

@ -3936,24 +3936,39 @@ impl Bank {
txs.zip(lock_results)
.map(|(tx, lock_res)| match lock_res {
Ok(()) => {
let recent_blockhash = tx.message().recent_blockhash();
if hash_queue.is_hash_valid_for_age(recent_blockhash, max_age) {
(Ok(()), None)
} else if let Some((address, account)) =
self.check_transaction_for_nonce(tx, &next_durable_nonce)
{
(Ok(()), Some(NoncePartial::new(address, account)))
} else {
error_counters.blockhash_not_found += 1;
(Err(TransactionError::BlockhashNotFound), None)
}
}
Ok(()) => self.check_transaction_age(
tx,
max_age,
&next_durable_nonce,
&hash_queue,
error_counters,
),
Err(e) => (Err(e.clone()), None),
})
.collect()
}
fn check_transaction_age(
&self,
tx: &SanitizedTransaction,
max_age: usize,
next_durable_nonce: &DurableNonce,
hash_queue: &BlockhashQueue,
error_counters: &mut TransactionErrorMetrics,
) -> TransactionCheckResult {
let recent_blockhash = tx.message().recent_blockhash();
if hash_queue.is_hash_valid_for_age(recent_blockhash, max_age) {
(Ok(()), None)
} else if let Some((address, account)) =
self.check_transaction_for_nonce(tx, next_durable_nonce)
{
(Ok(()), Some(NoncePartial::new(address, account)))
} else {
error_counters.blockhash_not_found += 1;
(Err(TransactionError::BlockhashNotFound), None)
}
}
fn is_transaction_already_processed(
&self,
sanitized_tx: &SanitizedTransaction,