Update geyser interface to not require write locks (#30380)
Update gesyer plugin interface to not require write locks
This commit is contained in:
parent
ad6a3abd8b
commit
fba990654b
|
@ -268,7 +268,7 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {
|
||||||
/// the account is updated during transaction processing.
|
/// the account is updated during transaction processing.
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn update_account(
|
fn update_account(
|
||||||
&mut self,
|
&self,
|
||||||
account: ReplicaAccountInfoVersions,
|
account: ReplicaAccountInfoVersions,
|
||||||
slot: u64,
|
slot: u64,
|
||||||
is_startup: bool,
|
is_startup: bool,
|
||||||
|
@ -277,25 +277,20 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when all accounts are notified of during startup.
|
/// Called when all accounts are notified of during startup.
|
||||||
fn notify_end_of_startup(&mut self) -> Result<()> {
|
fn notify_end_of_startup(&self) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when a slot status is updated
|
/// Called when a slot status is updated
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn update_slot_status(
|
fn update_slot_status(&self, slot: u64, parent: Option<u64>, status: SlotStatus) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
slot: u64,
|
|
||||||
parent: Option<u64>,
|
|
||||||
status: SlotStatus,
|
|
||||||
) -> Result<()> {
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when a transaction is updated at a slot.
|
/// Called when a transaction is updated at a slot.
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn notify_transaction(
|
fn notify_transaction(
|
||||||
&mut self,
|
&self,
|
||||||
transaction: ReplicaTransactionInfoVersions,
|
transaction: ReplicaTransactionInfoVersions,
|
||||||
slot: u64,
|
slot: u64,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
@ -304,7 +299,7 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {
|
||||||
|
|
||||||
/// Called when block's metadata is updated.
|
/// Called when block's metadata is updated.
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn notify_block_metadata(&mut self, blockinfo: ReplicaBlockInfoVersions) -> Result<()> {
|
fn notify_block_metadata(&self, blockinfo: ReplicaBlockInfoVersions) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,12 +68,12 @@ impl AccountsUpdateNotifierInterface for AccountsUpdateNotifierImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify_end_of_restore_from_snapshot(&self) {
|
fn notify_end_of_restore_from_snapshot(&self) {
|
||||||
let mut plugin_manager = self.plugin_manager.write().unwrap();
|
let plugin_manager = self.plugin_manager.read().unwrap();
|
||||||
if plugin_manager.plugins.is_empty() {
|
if plugin_manager.plugins.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for plugin in plugin_manager.plugins.iter_mut() {
|
for plugin in plugin_manager.plugins.iter() {
|
||||||
let mut measure = Measure::start("geyser-plugin-end-of-restore-from-snapshot");
|
let mut measure = Measure::start("geyser-plugin-end-of-restore-from-snapshot");
|
||||||
match plugin.notify_end_of_startup() {
|
match plugin.notify_end_of_startup() {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -146,12 +146,12 @@ impl AccountsUpdateNotifierImpl {
|
||||||
is_startup: bool,
|
is_startup: bool,
|
||||||
) {
|
) {
|
||||||
let mut measure2 = Measure::start("geyser-plugin-notify_plugins_of_account_update");
|
let mut measure2 = Measure::start("geyser-plugin-notify_plugins_of_account_update");
|
||||||
let mut plugin_manager = self.plugin_manager.write().unwrap();
|
let plugin_manager = self.plugin_manager.read().unwrap();
|
||||||
|
|
||||||
if plugin_manager.plugins.is_empty() {
|
if plugin_manager.plugins.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for plugin in plugin_manager.plugins.iter_mut() {
|
for plugin in plugin_manager.plugins.iter() {
|
||||||
let mut measure = Measure::start("geyser-plugin-update-account");
|
let mut measure = Measure::start("geyser-plugin-update-account");
|
||||||
match plugin.update_account(
|
match plugin.update_account(
|
||||||
ReplicaAccountInfoVersions::V0_0_3(&account),
|
ReplicaAccountInfoVersions::V0_0_3(&account),
|
||||||
|
|
|
@ -32,13 +32,13 @@ impl BlockMetadataNotifier for BlockMetadataNotifierImpl {
|
||||||
block_height: Option<u64>,
|
block_height: Option<u64>,
|
||||||
executed_transaction_count: u64,
|
executed_transaction_count: u64,
|
||||||
) {
|
) {
|
||||||
let mut plugin_manager = self.plugin_manager.write().unwrap();
|
let plugin_manager = self.plugin_manager.read().unwrap();
|
||||||
if plugin_manager.plugins.is_empty() {
|
if plugin_manager.plugins.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let rewards = Self::build_rewards(rewards);
|
let rewards = Self::build_rewards(rewards);
|
||||||
|
|
||||||
for plugin in plugin_manager.plugins.iter_mut() {
|
for plugin in plugin_manager.plugins.iter() {
|
||||||
let mut measure = Measure::start("geyser-plugin-update-slot");
|
let mut measure = Measure::start("geyser-plugin-update-slot");
|
||||||
let block_info = Self::build_replica_block_info(
|
let block_info = Self::build_replica_block_info(
|
||||||
parent_slot,
|
parent_slot,
|
||||||
|
|
|
@ -45,12 +45,12 @@ impl SlotStatusNotifierImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify_slot_status(&self, slot: Slot, parent: Option<Slot>, slot_status: SlotStatus) {
|
pub fn notify_slot_status(&self, slot: Slot, parent: Option<Slot>, slot_status: SlotStatus) {
|
||||||
let mut plugin_manager = self.plugin_manager.write().unwrap();
|
let plugin_manager = self.plugin_manager.read().unwrap();
|
||||||
if plugin_manager.plugins.is_empty() {
|
if plugin_manager.plugins.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for plugin in plugin_manager.plugins.iter_mut() {
|
for plugin in plugin_manager.plugins.iter() {
|
||||||
let mut measure = Measure::start("geyser-plugin-update-slot");
|
let mut measure = Measure::start("geyser-plugin-update-slot");
|
||||||
match plugin.update_slot_status(slot, parent, slot_status) {
|
match plugin.update_slot_status(slot, parent, slot_status) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
@ -38,13 +38,13 @@ impl TransactionNotifier for TransactionNotifierImpl {
|
||||||
transaction,
|
transaction,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut plugin_manager = self.plugin_manager.write().unwrap();
|
let plugin_manager = self.plugin_manager.read().unwrap();
|
||||||
|
|
||||||
if plugin_manager.plugins.is_empty() {
|
if plugin_manager.plugins.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for plugin in plugin_manager.plugins.iter_mut() {
|
for plugin in plugin_manager.plugins.iter() {
|
||||||
if !plugin.transaction_notifications_enabled() {
|
if !plugin.transaction_notifications_enabled() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue