Skip to content

Commit

Permalink
Option<Vec>
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Aug 23, 2024
1 parent a3b52fe commit 2ba61d0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions accounts-db/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,10 @@ impl Accounts {
pub fn store_cached<'a>(
&self,
accounts: impl StorableAccounts<'a>,
transactions: &'a [&'a SanitizedTransaction],
transactions: Option<&'a [&'a SanitizedTransaction]>,
) {
self.accounts_db
.store_cached_inline_update_index(accounts, Some(transactions));
.store_cached_inline_update_index(accounts, transactions);
}

pub fn store_accounts_cached<'a>(&self, accounts: impl StorableAccounts<'a>) {
Expand Down
7 changes: 4 additions & 3 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3801,9 +3801,10 @@ impl Bank {
&durable_nonce,
lamports_per_signature,
);
self.rc
.accounts
.store_cached((self.slot(), accounts_to_store.as_slice()), &transactions);
self.rc.accounts.store_cached(
(self.slot(), accounts_to_store.as_slice()),
transactions.as_deref(),
);
});

self.collect_rent(&processing_results);
Expand Down
5 changes: 3 additions & 2 deletions svm/src/account_saver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn collect_accounts_to_store<'a, T: SVMMessage>(
processing_results: &'a mut [TransactionProcessingResult],
durable_nonce: &DurableNonce,
lamports_per_signature: u64,
) -> (Vec<(&'a Pubkey, &'a AccountSharedData)>, Vec<&'a T>) {
) -> (Vec<(&'a Pubkey, &'a AccountSharedData)>, Option<Vec<&'a T>>) {
let collect_capacity = max_number_of_accounts_to_collect(txs, processing_results);
let mut accounts = Vec::with_capacity(collect_capacity);
let mut transactions = Vec::with_capacity(collect_capacity);
Expand Down Expand Up @@ -87,7 +87,7 @@ pub fn collect_accounts_to_store<'a, T: SVMMessage>(
}
}
}
(accounts, transactions)
(accounts, Some(transactions))
}

fn collect_accounts_for_successful_tx<'a, T: SVMMessage>(
Expand Down Expand Up @@ -294,6 +294,7 @@ mod tests {
.iter()
.any(|(pubkey, _account)| *pubkey == &keypair1.pubkey()));

let transactions = transactions.unwrap();
assert_eq!(transactions.len(), 2);
assert!(transactions.iter().any(|txn| (*txn).eq(&tx0)));
assert!(transactions.iter().any(|txn| (*txn).eq(&tx1)));
Expand Down

0 comments on commit 2ba61d0

Please sign in to comment.