Skip to main content

sol_parser_sdk/shredstream/
mod.rs

1//! ShredStream 模块 - Jito ShredStream 超低延迟交易订阅
2//!
3//! 提供从 Jito ShredStream 直接订阅 Solana Entry 数据的能力,
4//! 相比 gRPC 订阅具有更低的延迟(约 50-100ms 优势)。
5//!
6//! 实现拆分:`client` 负责网络与队列;`pump_ix` 为 **DEX 外层**指令热路径:
7//! Pump.fun 使用专用解析,其它已支持池子协议复用 `instr::parse_instruction_unified`;
8//!
9//! ## 使用示例
10//! ```rust,no_run
11//! use sol_parser_sdk::shredstream::{ShredStreamClient, ShredStreamConfig};
12//!
13//! #[tokio::main]
14//! async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
15//!     let client = ShredStreamClient::new("http://localhost:10800").await?;
16//!
17//!     // 订阅并获取事件队列
18//!     let queue = client.subscribe().await?;
19//!
20//!     // 消费事件
21//!     loop {
22//!         if let Some(event) = queue.pop() {
23//!             println!("Received: {:?}", event);
24//!         } else {
25//!             std::hint::spin_loop();
26//!         }
27//!     }
28//! }
29//! ```
30//!
31//! ## 限制说明
32//! ShredStream 相比 gRPC 订阅有以下限制:
33//! - 仅 `static_account_keys()`:V0 交易若带 **地址查找表(ALT)**,超出静态表的账户索引无法解析,对应腿可能解析失败;无 ALT 时静态表即全表。
34//! - 不解析 **inner instructions**:只覆盖外层指令可解析的事件;若事件只存在于 CPI/Program log,需使用 gRPC/RPC 路径。
35//! - 无 block_time,恒为 0
36//! - tx_index 在单个 ShredStream payload 内递增,不保证等同于完整 slot 全局交易索引
37
38pub mod client;
39pub mod config;
40pub mod proto;
41pub(crate) mod pump_ix;
42
43pub use client::ShredStreamClient;
44pub use config::ShredStreamConfig;
45pub use pump_ix::{parse_transaction_dex_events, parse_transaction_dex_events_with_filter};