Skip to content

Commit

Permalink
dont need to collect lock results
Browse files Browse the repository at this point in the history
  • Loading branch information
2501babe committed Jan 17, 2025
1 parent be461b5 commit cd7d890
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions accounts-db/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,11 @@ impl Accounts {
relax_intrabatch_account_locks: bool,
) -> Vec<Result<()>> {
// Validate the account locks, then get iterator if successful validation.
let tx_account_locks_results: Vec<Result<_>> = txs
let tx_account_locks_results = txs
.map(|tx| {
validate_account_locks(tx.account_keys(), tx_account_lock_limit)
.map(|_| TransactionAccountLocksIterator::new(tx))
})
.collect();
});
self.lock_accounts_inner(tx_account_locks_results, relax_intrabatch_account_locks)
}

Expand All @@ -583,27 +582,25 @@ impl Accounts {
relax_intrabatch_account_locks: bool,
) -> Vec<Result<()>> {
// Validate the account locks, then get iterator if successful validation.
let tx_account_locks_results: Vec<Result<_>> = txs
let tx_account_locks_results = txs
.zip(results)
.map(|(tx, result)| match result {
Ok(()) => validate_account_locks(tx.account_keys(), tx_account_lock_limit)
.map(|_| TransactionAccountLocksIterator::new(tx)),
Err(err) => Err(err),
})
.collect();
});
self.lock_accounts_inner(tx_account_locks_results, relax_intrabatch_account_locks)
}

#[must_use]
fn lock_accounts_inner(
fn lock_accounts_inner<'a>(
&self,
tx_account_locks_results: Vec<Result<TransactionAccountLocksIterator<impl SVMMessage>>>,
tx_account_locks_results: impl Iterator<Item = Result<TransactionAccountLocksIterator<'a, impl SVMMessage + 'a>>>,
relax_intrabatch_account_locks: bool,
) -> Vec<Result<()>> {
let account_locks = &mut self.account_locks.lock().unwrap();
if relax_intrabatch_account_locks {
let validated_batch_keys = tx_account_locks_results
.into_iter()
.map(|tx_account_locks_result| {
tx_account_locks_result
.map(|tx_account_locks| tx_account_locks.accounts_with_is_writable())
Expand All @@ -613,7 +610,6 @@ impl Accounts {
account_locks.try_lock_transaction_batch(validated_batch_keys)
} else {
tx_account_locks_results
.into_iter()
.map(|tx_account_locks_result| match tx_account_locks_result {
Ok(tx_account_locks) => account_locks
.try_lock_accounts(tx_account_locks.accounts_with_is_writable()),
Expand Down

0 comments on commit cd7d890

Please sign in to comment.