Skip to content

Commit

Permalink
PrioGraphScheduler::try_schedule_transaction remove TransactionAccoun…
Browse files Browse the repository at this point in the history
…tLocks allocation (#1760)
  • Loading branch information
apfitzge authored Jul 3, 2024
1 parent bfde5e0 commit 8f8f87b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,20 @@ fn try_schedule_transaction(
}

// Schedule the transaction if it can be.
let transaction_locks = transaction.get_account_locks_unchecked();
let message = transaction.message();
let account_keys = message.account_keys();
let write_account_locks = account_keys
.iter()
.enumerate()
.filter_map(|(index, key)| message.is_writable(index).then_some(key));
let read_account_locks = account_keys
.iter()
.enumerate()
.filter_map(|(index, key)| (!message.is_writable(index)).then_some(key));

let Some(thread_id) = account_locks.try_lock_accounts(
transaction_locks.writable.into_iter(),
transaction_locks.readonly.into_iter(),
write_account_locks,
read_account_locks,
ThreadSet::any(num_threads),
thread_selector,
) else {
Expand Down
4 changes: 2 additions & 2 deletions sdk/program/src/message/account_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'a> AccountKeys<'a> {
/// Returns an iterator of account key segments. The ordering of segments
/// affects how account indexes from compiled instructions are resolved and
/// so should not be changed.
fn key_segment_iter(&self) -> impl Iterator<Item = &'a [Pubkey]> {
fn key_segment_iter(&self) -> impl Iterator<Item = &'a [Pubkey]> + Clone {
if let Some(dynamic_keys) = self.dynamic_keys {
[
self.static_keys,
Expand Down Expand Up @@ -77,7 +77,7 @@ impl<'a> AccountKeys<'a> {
}

/// Iterator for the addresses of the loaded accounts for a message
pub fn iter(&self) -> impl Iterator<Item = &'a Pubkey> {
pub fn iter(&self) -> impl Iterator<Item = &'a Pubkey> + Clone {
self.key_segment_iter().flatten()
}

Expand Down

0 comments on commit 8f8f87b

Please sign in to comment.