pub trait Plugin:
Send
+ Sync
+ 'static {
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn on_load<'a>(&'a self) -> PluginFuture<'a> { ... }
fn on_block<'a>(&'a self, _block: &'a BlockData) -> PluginFuture<'a> { ... }
fn on_transaction<'a>(
&'a self,
_tx: &'a TransactionData,
) -> PluginFuture<'a> { ... }
fn on_token_transfer<'a>(
&'a self,
_transfer: &'a TokenTransferData,
) -> PluginFuture<'a> { ... }
fn on_account_activity<'a>(
&'a self,
_activity: &'a AccountActivityData,
) -> PluginFuture<'a> { ... }
fn on_skipped_slot<'a>(&'a self, _slot: u64) -> PluginFuture<'a> { ... }
fn on_raw_block<'a>(
&'a self,
_slot: u64,
_raw: &'a Value,
) -> PluginFuture<'a> { ... }
fn on_exit<'a>(&'a self) -> PluginFuture<'a> { ... }
}Expand description
Observe Solana block and transaction events.
Register your plugin with CascadeRunner::with_plugin()
and the framework handles all fetching, retries, parallelism, and cursor management.
All hooks have default no-op implementations. Override only the events you care about.
§Example
use quicknode_cascade::solana::{Plugin, PluginFuture, BlockData, TransactionData};
struct MyIndexer;
impl Plugin for MyIndexer {
fn name(&self) -> &'static str { "my-indexer" }
fn on_block<'a>(&'a self, block: &'a BlockData) -> PluginFuture<'a> {
Box::pin(async move {
println!("slot {} — {} txs", block.slot, block.transaction_count);
Ok(())
})
}
fn on_transaction<'a>(&'a self, tx: &'a TransactionData) -> PluginFuture<'a> {
Box::pin(async move {
if !tx.is_vote {
println!(" tx {}", tx.signature);
}
Ok(())
})
}
}Required Methods§
Provided Methods§
Sourcefn on_load<'a>(&'a self) -> PluginFuture<'a>
fn on_load<'a>(&'a self) -> PluginFuture<'a>
Called once when the runner starts, before any data is fetched. Use this to create tables, open connections, or validate config.
Sourcefn on_block<'a>(&'a self, _block: &'a BlockData) -> PluginFuture<'a>
fn on_block<'a>(&'a self, _block: &'a BlockData) -> PluginFuture<'a>
Called for each block. Fired once per slot, before transactions.
Sourcefn on_transaction<'a>(&'a self, _tx: &'a TransactionData) -> PluginFuture<'a>
fn on_transaction<'a>(&'a self, _tx: &'a TransactionData) -> PluginFuture<'a>
Called for each transaction within a block.
Fired in order of tx_index within the slot.
Sourcefn on_token_transfer<'a>(
&'a self,
_transfer: &'a TokenTransferData,
) -> PluginFuture<'a>
fn on_token_transfer<'a>( &'a self, _transfer: &'a TokenTransferData, ) -> PluginFuture<'a>
Called for each token balance change within a transaction. Only fired when the balance actually changed (pre != post).
Sourcefn on_account_activity<'a>(
&'a self,
_activity: &'a AccountActivityData,
) -> PluginFuture<'a>
fn on_account_activity<'a>( &'a self, _activity: &'a AccountActivityData, ) -> PluginFuture<'a>
Called for each account touched by a transaction (SOL balance changes).
Sourcefn on_skipped_slot<'a>(&'a self, _slot: u64) -> PluginFuture<'a>
fn on_skipped_slot<'a>(&'a self, _slot: u64) -> PluginFuture<'a>
Called when a slot was skipped by the Solana leader (no block produced).
Sourcefn on_raw_block<'a>(&'a self, _slot: u64, _raw: &'a Value) -> PluginFuture<'a>
fn on_raw_block<'a>(&'a self, _slot: u64, _raw: &'a Value) -> PluginFuture<'a>
Called for each slot in raw mode. Receives the full JSON-RPC response. Only fired when the runner is in raw encoding mode.
Sourcefn on_exit<'a>(&'a self) -> PluginFuture<'a>
fn on_exit<'a>(&'a self) -> PluginFuture<'a>
Called once when the runner is shutting down. Flush buffers, close connections.