Skip to content

Commit

Permalink
use u64 to track write-version, manual iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed Aug 27, 2024
1 parent 2ba61d0 commit 2557ee5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
15 changes: 6 additions & 9 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ use {
hash::Hash,
pubkey::Pubkey,
rent_collector::RentCollector,
saturating_add_assign,
timing::AtomicInterval,
transaction::SanitizedTransaction,
},
Expand Down Expand Up @@ -6811,14 +6812,9 @@ impl AccountsDb {
accounts_and_meta_to_store: &impl StorableAccounts<'b>,
mut txn_iter: impl Iterator<Item = &'a SanitizedTransaction>,
) -> Vec<AccountInfo> {
let mut write_version_producer = if self.accounts_update_notifier.is_some() {
let current_version = self
.write_version
.fetch_add(accounts_and_meta_to_store.len() as u64, Ordering::AcqRel);
current_version..current_version + accounts_and_meta_to_store.len() as u64
} else {
0..0 // dummy empty iterator
};
let mut current_write_version = self
.write_version
.fetch_add(accounts_and_meta_to_store.len() as u64, Ordering::AcqRel);

let (account_infos, cached_accounts) = (0..accounts_and_meta_to_store.len())
.map(|index| {
Expand All @@ -6834,8 +6830,9 @@ impl AccountsDb {
&account_shared_data,
txn,
pubkey,
&mut write_version_producer,
current_write_version,
);
saturating_add_assign!(current_write_version, 1);

let cached_account =
self.accounts_cache.store(slot, pubkey, account_shared_data);
Expand Down
10 changes: 4 additions & 6 deletions accounts-db/src/accounts_db/geyser_plugin_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,21 @@ impl AccountsDb {
notify_stats.report();
}

pub fn notify_account_at_accounts_update<P>(
pub fn notify_account_at_accounts_update(
&self,
slot: Slot,
account: &AccountSharedData,
txn: &Option<&SanitizedTransaction>,
pubkey: &Pubkey,
write_version_producer: &mut P,
) where
P: Iterator<Item = u64>,
{
write_version: u64,
) {
if let Some(accounts_update_notifier) = &self.accounts_update_notifier {
accounts_update_notifier.notify_account_update(
slot,
account,
txn,
pubkey,
write_version_producer.next().unwrap(),
write_version,
);
}
}
Expand Down

0 comments on commit 2557ee5

Please sign in to comment.