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) txs.zip(lock_results)
.map(|(tx, lock_res)| match lock_res { .map(|(tx, lock_res)| match lock_res {
Ok(()) => { Ok(()) => self.check_transaction_age(
let recent_blockhash = tx.message().recent_blockhash(); tx,
if hash_queue.is_hash_valid_for_age(recent_blockhash, max_age) { max_age,
(Ok(()), None) &next_durable_nonce,
} else if let Some((address, account)) = &hash_queue,
self.check_transaction_for_nonce(tx, &next_durable_nonce) error_counters,
{ ),
(Ok(()), Some(NoncePartial::new(address, account)))
} else {
error_counters.blockhash_not_found += 1;
(Err(TransactionError::BlockhashNotFound), None)
}
}
Err(e) => (Err(e.clone()), None), Err(e) => (Err(e.clone()), None),
}) })
.collect() .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( fn is_transaction_already_processed(
&self, &self,
sanitized_tx: &SanitizedTransaction, sanitized_tx: &SanitizedTransaction,