diff --git a/accounts-db/src/accounts_db/geyser_plugin_utils.rs b/accounts-db/src/accounts_db/geyser_plugin_utils.rs index 0fbc11c079..1efd678873 100644 --- a/accounts-db/src/accounts_db/geyser_plugin_utils.rs +++ b/accounts-db/src/accounts_db/geyser_plugin_utils.rs @@ -56,8 +56,7 @@ impl AccountsDb { } let accounts_update_notifier = self.accounts_update_notifier.as_ref().unwrap(); - let notifier = &accounts_update_notifier.read().unwrap(); - notifier.notify_end_of_restore_from_snapshot(); + accounts_update_notifier.notify_end_of_restore_from_snapshot(); notify_stats.report(); } @@ -72,8 +71,7 @@ impl AccountsDb { P: Iterator, { if let Some(accounts_update_notifier) = &self.accounts_update_notifier { - let notifier = &accounts_update_notifier.read().unwrap(); - notifier.notify_account_update( + accounts_update_notifier.notify_account_update( slot, account, txn, @@ -121,13 +119,7 @@ impl AccountsDb { mut accounts_to_stream: HashMap, notify_stats: &mut GeyserPluginNotifyAtSnapshotRestoreStats, ) { - let notifier = self - .accounts_update_notifier - .as_ref() - .unwrap() - .read() - .unwrap(); - + let notifier = self.accounts_update_notifier.as_ref().unwrap(); let mut measure_notify = Measure::start("accountsdb-plugin-notifying-accounts"); let local_write_version = 0; for (_, mut account) in accounts_to_stream.drain() { @@ -177,7 +169,7 @@ pub mod tests { }, std::sync::{ atomic::{AtomicBool, Ordering}, - Arc, RwLock, + Arc, }, }; @@ -246,12 +238,11 @@ pub mod tests { accounts.store_uncached(slot0, &[(&key2, &account2)]); - let notifier = Arc::new(RwLock::new(notifier)); + let notifier = Arc::new(notifier); accounts.set_geyser_plugin_notifer(Some(notifier.clone())); accounts.notify_account_restore_from_snapshot(); - let notifier = notifier.write().unwrap(); assert_eq!(notifier.accounts_notified.get(&key1).unwrap().len(), 1); assert_eq!( notifier.accounts_notified.get(&key1).unwrap()[0] @@ -303,12 +294,11 @@ pub mod tests { AccountSharedData::new(account3_lamports, 1, AccountSharedData::default().owner()); accounts.store_uncached(slot1, &[(&key3, &account3)]); - let notifier = Arc::new(RwLock::new(notifier)); + let notifier = Arc::new(notifier); accounts.set_geyser_plugin_notifer(Some(notifier.clone())); accounts.notify_account_restore_from_snapshot(); - let notifier = notifier.write().unwrap(); assert_eq!(notifier.accounts_notified.get(&key1).unwrap().len(), 1); assert_eq!( notifier.accounts_notified.get(&key1).unwrap()[0] @@ -342,7 +332,7 @@ pub mod tests { let notifier = GeyserTestPlugin::default(); - let notifier = Arc::new(RwLock::new(notifier)); + let notifier = Arc::new(notifier); accounts.set_geyser_plugin_notifer(Some(notifier.clone())); // Account with key1 is updated twice in two different slots -- should only get notified twice. @@ -372,7 +362,6 @@ pub mod tests { AccountSharedData::new(account3_lamports, 1, AccountSharedData::default().owner()); accounts.store_cached((slot1, &[(&key3, &account3)][..]), None); - let notifier = notifier.write().unwrap(); assert_eq!(notifier.accounts_notified.get(&key1).unwrap().len(), 2); assert_eq!( notifier.accounts_notified.get(&key1).unwrap()[0] diff --git a/accounts-db/src/accounts_update_notifier_interface.rs b/accounts-db/src/accounts_update_notifier_interface.rs index ae31cb06d3..ec86fce8cd 100644 --- a/accounts-db/src/accounts_update_notifier_interface.rs +++ b/accounts-db/src/accounts_update_notifier_interface.rs @@ -3,7 +3,7 @@ use { solana_sdk::{ account::AccountSharedData, clock::Slot, pubkey::Pubkey, transaction::SanitizedTransaction, }, - std::sync::{Arc, RwLock}, + std::sync::Arc, }; pub trait AccountsUpdateNotifierInterface: std::fmt::Debug { @@ -25,4 +25,4 @@ pub trait AccountsUpdateNotifierInterface: std::fmt::Debug { fn notify_end_of_restore_from_snapshot(&self); } -pub type AccountsUpdateNotifier = Arc>; +pub type AccountsUpdateNotifier = Arc; diff --git a/geyser-plugin-manager/src/geyser_plugin_service.rs b/geyser-plugin-manager/src/geyser_plugin_service.rs index b762c210e4..a95c1b7e1a 100644 --- a/geyser-plugin-manager/src/geyser_plugin_service.rs +++ b/geyser-plugin-manager/src/geyser_plugin_service.rs @@ -87,7 +87,7 @@ impl GeyserPluginService { if account_data_notifications_enabled { let accounts_update_notifier = AccountsUpdateNotifierImpl::new(plugin_manager.clone()); - Some(Arc::new(RwLock::new(accounts_update_notifier))) + Some(Arc::new(accounts_update_notifier)) } else { None };