separate check_transaction_age from check_age (#30994)
This commit is contained in:
parent
03abaf76d0
commit
15011eaa5a
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue