pub trait GeyserPlugin:
Any
+ Send
+ Sync
+ Debug {
Show 13 methods
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn setup_logger(
&self,
logger: &'static dyn Log,
level: LevelFilter,
) -> Result<()> { ... }
fn on_load(&mut self, _config_file: &str, _is_reload: bool) -> Result<()> { ... }
fn on_unload(&mut self) { ... }
fn update_account(
&self,
account: ReplicaAccountInfoVersions<'_>,
slot: Slot,
is_startup: bool,
) -> Result<()> { ... }
fn notify_end_of_startup(&self) -> Result<()> { ... }
fn update_slot_status(
&self,
slot: Slot,
parent: Option<u64>,
status: SlotStatus,
) -> Result<()> { ... }
fn notify_transaction(
&self,
transaction: ReplicaTransactionInfoVersions<'_>,
slot: Slot,
) -> Result<()> { ... }
fn notify_entry(&self, entry: ReplicaEntryInfoVersions<'_>) -> Result<()> { ... }
fn notify_block_metadata(
&self,
blockinfo: ReplicaBlockInfoVersions<'_>,
) -> Result<()> { ... }
fn account_data_notifications_enabled(&self) -> bool { ... }
fn transaction_notifications_enabled(&self) -> bool { ... }
fn entry_notifications_enabled(&self) -> bool { ... }
}
Expand description
Defines a Geyser plugin, to stream data from the runtime. Geyser plugins must describe desired behavior for load and unload, as well as how they will handle streamed data.
Required Methods§
Provided Methods§
sourcefn setup_logger(
&self,
logger: &'static dyn Log,
level: LevelFilter,
) -> Result<()>
fn setup_logger( &self, logger: &'static dyn Log, level: LevelFilter, ) -> Result<()>
The callback to allow the plugin to setup the logging configuration using the logger and log level specified by the validator. Will be called first on load/reload, before any other callback, and only called once.
§Examples
use solana_geyser_plugin_interface::geyser_plugin_interface::{GeyserPlugin,
GeyserPluginError, Result};
#[derive(Debug)]
struct SamplePlugin;
impl GeyserPlugin for SamplePlugin {
fn setup_logger(&self, logger: &'static dyn log::Log, level: log::LevelFilter) -> Result<()> {
log::set_max_level(level);
if let Err(err) = log::set_logger(logger) {
return Err(GeyserPluginError::Custom(Box::new(err)));
}
Ok(())
}
fn name(&self) -> &'static str {
&"sample"
}
}
sourcefn on_load(&mut self, _config_file: &str, _is_reload: bool) -> Result<()>
fn on_load(&mut self, _config_file: &str, _is_reload: bool) -> Result<()>
The callback called when a plugin is loaded by the system, used for doing whatever initialization is required by the plugin. The _config_file contains the name of the of the config file. The config must be in JSON format and include a field “libpath” indicating the full path name of the shared library implementing this interface.
sourcefn on_unload(&mut self)
fn on_unload(&mut self)
The callback called right before a plugin is unloaded by the system Used for doing cleanup before unload.
sourcefn update_account(
&self,
account: ReplicaAccountInfoVersions<'_>,
slot: Slot,
is_startup: bool,
) -> Result<()>
fn update_account( &self, account: ReplicaAccountInfoVersions<'_>, slot: Slot, is_startup: bool, ) -> Result<()>
Called when an account is updated at a slot.
When is_startup
is true, it indicates the account is loaded from
snapshots when the validator starts up. When is_startup
is false,
the account is updated during transaction processing.
sourcefn notify_end_of_startup(&self) -> Result<()>
fn notify_end_of_startup(&self) -> Result<()>
Called when all accounts are notified of during startup.
sourcefn update_slot_status(
&self,
slot: Slot,
parent: Option<u64>,
status: SlotStatus,
) -> Result<()>
fn update_slot_status( &self, slot: Slot, parent: Option<u64>, status: SlotStatus, ) -> Result<()>
Called when a slot status is updated
sourcefn notify_transaction(
&self,
transaction: ReplicaTransactionInfoVersions<'_>,
slot: Slot,
) -> Result<()>
fn notify_transaction( &self, transaction: ReplicaTransactionInfoVersions<'_>, slot: Slot, ) -> Result<()>
Called when a transaction is processed in a slot.
sourcefn notify_entry(&self, entry: ReplicaEntryInfoVersions<'_>) -> Result<()>
fn notify_entry(&self, entry: ReplicaEntryInfoVersions<'_>) -> Result<()>
Called when an entry is executed.
sourcefn notify_block_metadata(
&self,
blockinfo: ReplicaBlockInfoVersions<'_>,
) -> Result<()>
fn notify_block_metadata( &self, blockinfo: ReplicaBlockInfoVersions<'_>, ) -> Result<()>
Called when block’s metadata is updated.
sourcefn account_data_notifications_enabled(&self) -> bool
fn account_data_notifications_enabled(&self) -> bool
Check if the plugin is interested in account data Default is true – if the plugin is not interested in account data, please return false.
sourcefn transaction_notifications_enabled(&self) -> bool
fn transaction_notifications_enabled(&self) -> bool
Check if the plugin is interested in transaction data Default is false – if the plugin is interested in transaction data, please return true.
sourcefn entry_notifications_enabled(&self) -> bool
fn entry_notifications_enabled(&self) -> bool
Check if the plugin is interested in entry data Default is false – if the plugin is interested in entry data, return true.