Skip to main content

GeyserPlugin

pub trait GeyserPlugin:
    Any
    + Send
    + Sync
    + Debug {
Show 20 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 notify_contact_info( &self, info: ReplicaContactInfoVersions<'_>, is_startup: bool, ) -> Result<()> { ... } fn notify_contact_info_removed(&self, pubkey: &[u8]) -> Result<()> { ... } fn account_data_notifications_enabled(&self) -> bool { ... } fn account_data_snapshot_notifications_enabled(&self) -> bool { ... } fn transaction_notifications_enabled(&self) -> bool { ... } fn entry_notifications_enabled(&self) -> bool { ... } fn contact_info_notifications_enabled(&self) -> bool { ... } fn notify_deshred_transaction( &self, transaction: ReplicaDeshredTransactionInfoVersions<'_>, slot: Slot, ) -> Result<()> { ... } fn deshred_transaction_notifications_enabled(&self) -> bool { ... } fn deshred_transaction_alt_resolution_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§

Source

fn name(&self) -> &'static str

Provided Methods§

Source

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 agave_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"
    }
}
Source

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.

Source

fn on_unload(&mut self)

The callback called right before a plugin is unloaded by the system Used for doing cleanup before unload.

Source

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.

Source

fn notify_end_of_startup(&self) -> Result<()>

Called when all accounts are notified of during startup.

Source

fn update_slot_status( &self, slot: Slot, parent: Option<u64>, status: &SlotStatus, ) -> Result<()>

Called when a slot status is updated

Source

fn notify_transaction( &self, transaction: ReplicaTransactionInfoVersions<'_>, slot: Slot, ) -> Result<()>

Called when a transaction is processed in a slot.

Source

fn notify_entry(&self, entry: ReplicaEntryInfoVersions<'_>) -> Result<()>

Called when an entry is executed.

Source

fn notify_block_metadata( &self, blockinfo: ReplicaBlockInfoVersions<'_>, ) -> Result<()>

Called when block’s metadata is updated.

Source

fn notify_contact_info( &self, info: ReplicaContactInfoVersions<'_>, is_startup: bool, ) -> Result<()>

Called when a validator’s gossip contact info is learned or updated.

is_startup is true when this call is part of the initial state dump delivered synchronously after the plugin is loaded (every currently-known validator’s latest contact info is delivered once with is_startup=true before any live updates). Subsequent live updates driven by gossip activity are delivered with is_startup=false.

Delivery is best-effort: under extreme load, updates may be dropped to keep the gossip subsystem unaffected. Contact info is rebroadcast on a multi-second cadence by validators, so consumers self-heal on the next republish.

Only called when contact_info_notifications_enabled() returns true.

Source

fn notify_contact_info_removed(&self, pubkey: &[u8]) -> Result<()>

Called when a validator’s gossip contact info is removed from CRDS. Plugins that maintain a cache keyed on validator identity should invalidate the entry for pubkey on receipt of this notification.

Fires for both timeout-based purges (the validator stopped gossiping; their entry aged out per stake-aware CRDS timeouts) and size-based trims (CRDS exceeded its capacity and evicted older entries). The pubkey is the 32-byte validator identity that was last seen via notify_contact_info.

Like notify_contact_info, this is best-effort: under extreme load a removal event may be dropped (the gossip_contact_info_dropped counter is bumped when this happens). Consumers that need strict liveness guarantees should pair this notification with their own wallclock-staleness check on cached entries.

Only called when contact_info_notifications_enabled() returns true.

Source

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.

Source

fn account_data_snapshot_notifications_enabled(&self) -> bool

Check if the plugin is interested in account data from snapshot Default is true – if the plugin is not interested in account data snapshot, please return false because startup would be improved significantly.

Source

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.

Source

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.

Source

fn contact_info_notifications_enabled(&self) -> bool

Check if the plugin is interested in validator contact info updates sourced from gossip. Default is false — if the plugin wants contact info notifications, return true. When no loaded plugin returns true, the validator bypasses all contact-info notification machinery (no dispatch thread, no channel, zero hot-path overhead).

Source

fn notify_deshred_transaction( &self, transaction: ReplicaDeshredTransactionInfoVersions<'_>, slot: Slot, ) -> Result<()>

Called when a transaction is deshredded (entries formed from shreds). This is triggered before any execution occurs. Unlike notify_transaction, this does not include execution metadata (TransactionStatusMeta).

Source

fn deshred_transaction_notifications_enabled(&self) -> bool

Check if the plugin is interested in deshred transaction data. Default is false – if the plugin is interested in receiving transactions when they are deshredded, return true.

Source

fn deshred_transaction_alt_resolution_enabled(&self) -> bool

Check if the plugin wants address lookup table (ALT) resolution for deshred transactions. Default is false. When true, the validator will resolve V0 transaction address lookups using the rooted bank and populate loaded_addresses in ReplicaDeshredTransactionInfo. This adds accounts DB I/O on the shred insertion path, so plugins that only need the raw transaction should leave this disabled.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§