Adding a method to check wheather to skip statup notifications from geyser
This commit is contained in:
parent
ada5796e7e
commit
1694cfd04c
|
@ -355,6 +355,10 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn skip_statup_notifications(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Check if the plugin is interested in account data
|
||||
/// Default is true -- if the plugin is not interested in
|
||||
/// account data, please return false.
|
||||
|
|
|
@ -22,6 +22,7 @@ use {
|
|||
#[derive(Debug)]
|
||||
pub(crate) struct AccountsUpdateNotifierImpl {
|
||||
plugin_manager: Arc<RwLock<GeyserPluginManager>>,
|
||||
skip_statup_notifications: bool,
|
||||
}
|
||||
|
||||
impl AccountsUpdateNotifierInterface for AccountsUpdateNotifierImpl {
|
||||
|
@ -41,6 +42,9 @@ impl AccountsUpdateNotifierInterface for AccountsUpdateNotifierImpl {
|
|||
}
|
||||
|
||||
fn notify_account_restore_from_snapshot(&self, slot: Slot, account: &StoredAccountMeta) {
|
||||
if self.skip_statup_notifications {
|
||||
return;
|
||||
}
|
||||
let mut measure_all = Measure::start("geyser-plugin-notify-account-restore-all");
|
||||
let mut measure_copy = Measure::start("geyser-plugin-copy-stored-account-info");
|
||||
|
||||
|
@ -100,8 +104,14 @@ impl AccountsUpdateNotifierInterface for AccountsUpdateNotifierImpl {
|
|||
}
|
||||
|
||||
impl AccountsUpdateNotifierImpl {
|
||||
pub fn new(plugin_manager: Arc<RwLock<GeyserPluginManager>>) -> Self {
|
||||
AccountsUpdateNotifierImpl { plugin_manager }
|
||||
pub fn new(
|
||||
plugin_manager: Arc<RwLock<GeyserPluginManager>>,
|
||||
skip_statup_notifications: bool,
|
||||
) -> Self {
|
||||
AccountsUpdateNotifierImpl {
|
||||
plugin_manager,
|
||||
skip_statup_notifications,
|
||||
}
|
||||
}
|
||||
|
||||
fn accountinfo_from_shared_account_data<'a>(
|
||||
|
|
|
@ -80,6 +80,15 @@ impl GeyserPluginManager {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn skip_statup_notifications(&self) -> bool {
|
||||
for plugin in &self.plugins {
|
||||
if !plugin.skip_statup_notifications() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
/// Check if there is any plugin interested in transaction data
|
||||
pub fn transaction_notifications_enabled(&self) -> bool {
|
||||
for plugin in &self.plugins {
|
||||
|
|
|
@ -79,14 +79,18 @@ impl GeyserPluginService {
|
|||
|
||||
let account_data_notifications_enabled =
|
||||
plugin_manager.account_data_notifications_enabled();
|
||||
|
||||
let skip_statup_notifications = plugin_manager.skip_statup_notifications();
|
||||
let transaction_notifications_enabled = plugin_manager.transaction_notifications_enabled();
|
||||
let entry_notifications_enabled = plugin_manager.entry_notifications_enabled();
|
||||
let plugin_manager = Arc::new(RwLock::new(plugin_manager));
|
||||
|
||||
let accounts_update_notifier: Option<AccountsUpdateNotifier> =
|
||||
if account_data_notifications_enabled {
|
||||
let accounts_update_notifier =
|
||||
AccountsUpdateNotifierImpl::new(plugin_manager.clone());
|
||||
let accounts_update_notifier = AccountsUpdateNotifierImpl::new(
|
||||
plugin_manager.clone(),
|
||||
skip_statup_notifications,
|
||||
);
|
||||
Some(Arc::new(RwLock::new(accounts_update_notifier)))
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -225,7 +225,7 @@ pub trait ReadableAccount: Sized {
|
|||
fn to_account_meta(&self) -> AccountMetaData {
|
||||
AccountMetaData {
|
||||
lamports: self.lamports(),
|
||||
owner: self.owner().clone(),
|
||||
owner: *self.owner(),
|
||||
rent_epoch: self.rent_epoch(),
|
||||
executable: self.executable(),
|
||||
space: self.data().len(),
|
||||
|
|
Loading…
Reference in New Issue