Skip to main content

Module shredstream

Module shredstream 

Source
Expand description

ShredStream 模块 - Jito ShredStream 超低延迟交易订阅

提供从 Jito ShredStream 直接订阅 Solana Entry 数据的能力, 相比 gRPC 订阅具有更低的延迟(约 50-100ms 优势)。

实现拆分:client 负责网络与队列;pump_ixDEX 外层指令热路径: Pump.fun 使用专用解析,其它已支持池子协议复用 instr::parse_instruction_unified

§使用示例

use sol_parser_sdk::shredstream::{ShredStreamClient, ShredStreamConfig};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
    let client = ShredStreamClient::new("http://localhost:10800").await?;

    // 订阅并获取事件队列
    let queue = client.subscribe().await?;

    // 消费事件
    loop {
        if let Some(event) = queue.pop() {
            println!("Received: {:?}", event);
        } else {
            std::hint::spin_loop();
        }
    }
}

§限制说明

ShredStream 相比 gRPC 订阅有以下限制:

  • static_account_keys():V0 交易若带 地址查找表(ALT),超出静态表的账户索引无法解析,对应腿可能解析失败;无 ALT 时静态表即全表。
  • 不解析 inner instructions:只覆盖外层指令可解析的事件;若事件只存在于 CPI/Program log,需使用 gRPC/RPC 路径。
  • 无 block_time,恒为 0
  • tx_index 在单个 ShredStream payload 内递增,不保证等同于完整 slot 全局交易索引

Re-exports§

pub use client::ShredStreamClient;
pub use config::ShredStreamConfig;

Modules§

client
ShredStream 客户端
config
ShredStream 配置
proto
ShredStream protobuf 定义

Functions§

parse_transaction_dex_events
parse_transaction_dex_events_with_filter