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` 为 **Pump 外层指令**零拷贝热路径解析(不克隆 `static_account_keys`、不复制 `CompiledInstruction`)。
7//!
8//! ## 使用示例
9//! ```rust,no_run
10//! use sol_parser_sdk::shredstream::{ShredStreamClient, ShredStreamConfig};
11//! use sol_parser_sdk::DexEvent;
12//!
13//! #[tokio::main]
14//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
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**:多笔买必须体现在 **多条外层** Pump `buy` / `buy_exact_sol_in` 上(铸币捆绑通常如此);若全塞进单条 outer 的 CPI 链则 ShredStream 无法逐腿还原。
35//! - 无 block_time,恒为 0
36//! - tx_index 是 entry 内索引而非 slot 内索引
37
38pub mod client;
39pub mod config;
40pub(crate) mod pump_ix;
41pub mod proto;
42
43pub use client::ShredStreamClient;
44pub use config::ShredStreamConfig;