Skip to main content

extract_block

Function extract_block 

Source
pub fn extract_block(slot: u64, block: Value) -> SlotExtract
Expand description

Extract structured data from a raw getBlock JSON-RPC response.

Takes ownership of the JSON Value (zero-copy where possible). Returns block metadata, transactions, token transfers, and account activity.

Use this from Plugin::on_slot if you want the framework’s extraction as a starting point alongside your own custom parsing.

§Example

use quicknode_cascade::solana::{self, Plugin, PluginFuture};

struct HybridPlugin;
impl Plugin for HybridPlugin {
    fn name(&self) -> &'static str { "hybrid" }
    fn on_slot<'a>(&'a self, slot: u64, raw: &'a serde_json::Value) -> PluginFuture<'a> {
        Box::pin(async move {
            // Use the framework's extraction
            let extracted = solana::extract_block(slot, raw.clone());
            println!("{} txs", extracted.transactions.len());

            // PLUS do your own custom parsing from the same raw JSON
            if let Some(rewards) = raw.get("rewards") {
                println!("rewards: {}", rewards);
            }
            Ok(())
        })
    }
}