Skip to content

Commit

Permalink
refactor: clean up geyser-plugin-manager (#1570)
Browse files Browse the repository at this point in the history
* Remove redundant Option return type from accountinfo_from_shared_account_data

* Remove redundant Option return type from accountinfo_from_stored_account_meta
  • Loading branch information
andreisilviudragnea authored Jun 17, 2024
1 parent 988647d commit f43cfc8
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions geyser-plugin-manager/src/accounts_update_notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ impl AccountsUpdateNotifierInterface for AccountsUpdateNotifierImpl {
pubkey: &Pubkey,
write_version: u64,
) {
if let Some(account_info) =
self.accountinfo_from_shared_account_data(account, txn, pubkey, write_version)
{
self.notify_plugins_of_account_update(account_info, slot, false);
}
let account_info =
self.accountinfo_from_shared_account_data(account, txn, pubkey, write_version);
self.notify_plugins_of_account_update(account_info, slot, false);
}

fn notify_account_restore_from_snapshot(&self, slot: Slot, account: &StoredAccountMeta) {
Expand All @@ -54,9 +52,8 @@ impl AccountsUpdateNotifierInterface for AccountsUpdateNotifierImpl {
100000
);

if let Some(account_info) = account {
self.notify_plugins_of_account_update(account_info, slot, true);
}
self.notify_plugins_of_account_update(account, slot, true);

measure_all.stop();

inc_new_counter_debug!(
Expand Down Expand Up @@ -110,8 +107,8 @@ impl AccountsUpdateNotifierImpl {
txn: &'a Option<&'a SanitizedTransaction>,
pubkey: &'a Pubkey,
write_version: u64,
) -> Option<ReplicaAccountInfoV3<'a>> {
Some(ReplicaAccountInfoV3 {
) -> ReplicaAccountInfoV3<'a> {
ReplicaAccountInfoV3 {
pubkey: pubkey.as_ref(),
lamports: account.lamports(),
owner: account.owner().as_ref(),
Expand All @@ -120,21 +117,21 @@ impl AccountsUpdateNotifierImpl {
data: account.data(),
write_version,
txn: *txn,
})
}
}

fn accountinfo_from_stored_account_meta<'a>(
&self,
stored_account_meta: &'a StoredAccountMeta,
) -> Option<ReplicaAccountInfoV3<'a>> {
) -> ReplicaAccountInfoV3<'a> {
// We do not need to rely on the specific write_version read from the append vec.
// So, overwrite the write_version with something that works.
// There is already only entry per pubkey.
// write_version is only used to order multiple entries with the same pubkey,
// so it doesn't matter what value it gets here.
// Passing 0 for everyone's write_version is sufficiently correct.
let write_version = 0;
Some(ReplicaAccountInfoV3 {
ReplicaAccountInfoV3 {
pubkey: stored_account_meta.pubkey().as_ref(),
lamports: stored_account_meta.lamports(),
owner: stored_account_meta.owner().as_ref(),
Expand All @@ -143,7 +140,7 @@ impl AccountsUpdateNotifierImpl {
data: stored_account_meta.data(),
write_version,
txn: None,
})
}
}

fn notify_plugins_of_account_update(
Expand Down

0 comments on commit f43cfc8

Please sign in to comment.