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//! `pfees_ix` 为 **Pump Fees(`pfee...`)** 外层指令热路径,**仅** `update_fee_shares` 会解析并入队。
9//!
10//! ## 使用示例
11//! ```rust,no_run
12//! use sol_parser_sdk::shredstream::{ShredStreamClient, ShredStreamConfig};
13//!
14//! #[tokio::main]
15//! async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
16//! let client = ShredStreamClient::new("http://localhost:10800").await?;
17//!
18//! // 订阅并获取事件队列
19//! let queue = client.subscribe().await?;
20//!
21//! // 消费事件
22//! loop {
23//! if let Some(event) = queue.pop() {
24//! println!("Received: {:?}", event);
25//! } else {
26//! std::hint::spin_loop();
27//! }
28//! }
29//! }
30//! ```
31//!
32//! ## 限制说明
33//! ShredStream 相比 gRPC 订阅有以下限制:
34//! - 仅 `static_account_keys()`:V0 交易若带 **地址查找表(ALT)**,超出静态表的账户索引无法解析,对应腿可能解析失败;无 ALT 时静态表即全表。
35//! - 不解析 **inner instructions**:只覆盖外层指令可解析的事件;若事件只存在于 CPI/Program log,需使用 gRPC/RPC 路径。
36//! - 无 block_time,恒为 0
37//! - tx_index 是 entry 内索引而非 slot 内索引
38
39pub mod client;
40pub mod config;
41pub(crate) mod pfees_ix;
42pub mod proto;
43pub(crate) mod pump_ix;
44
45pub use client::ShredStreamClient;
46pub use config::ShredStreamConfig;