Skip to content

Commit

Permalink
bank::(un)lock_accounts generic (#2835)
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge authored Sep 10, 2024
1 parent 91dfa6b commit fe64cf6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions accounts-db/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,9 @@ impl Accounts {
/// This function will prevent multiple threads from modifying the same account state at the
/// same time
#[must_use]
pub fn lock_accounts<'a>(
pub fn lock_accounts<'a, Tx: SVMMessage + 'a>(
&self,
txs: impl Iterator<Item = &'a SanitizedTransaction>,
txs: impl Iterator<Item = &'a Tx>,
tx_account_lock_limit: usize,
) -> Vec<Result<()>> {
// Validate the account locks, then get iterator if successful validation.
Expand Down Expand Up @@ -566,9 +566,9 @@ impl Accounts {
}

/// Once accounts are unlocked, new transactions that modify that state can enter the pipeline
pub fn unlock_accounts<'a>(
pub fn unlock_accounts<'a, Tx: SVMMessage + 'a>(
&self,
txs_and_results: impl Iterator<Item = (&'a SanitizedTransaction, &'a Result<()>)> + Clone,
txs_and_results: impl Iterator<Item = (&'a Tx, &'a Result<()>)> + Clone,
) {
if !txs_and_results.clone().any(|(_, res)| res.is_ok()) {
return;
Expand All @@ -578,7 +578,7 @@ impl Accounts {
debug!("bank unlock accounts");
for (tx, res) in txs_and_results {
if res.is_ok() {
let tx_account_locks = TransactionAccountLocksIterator::new(tx.message());
let tx_account_locks = TransactionAccountLocksIterator::new(tx);
account_locks.unlock_accounts(tx_account_locks.accounts_with_is_writable());
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3425,9 +3425,9 @@ impl Bank {
account_overrides
}

pub fn unlock_accounts<'a>(
pub fn unlock_accounts<'a, Tx: SVMMessage + 'a>(
&self,
txs_and_results: impl Iterator<Item = (&'a SanitizedTransaction, &'a Result<()>)> + Clone,
txs_and_results: impl Iterator<Item = (&'a Tx, &'a Result<()>)> + Clone,
) {
self.rc.accounts.unlock_accounts(txs_and_results)
}
Expand Down

0 comments on commit fe64cf6

Please sign in to comment.