mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-16 02:18:05 +00:00
feat: refactor to multi-protocol event streaming system
Major architectural refactor, upgrading from simple logging system to comprehensive multi-protocol Solana DEX event streaming system: ✨ New Features: - Support for 5 DEX protocols: PumpFun, PumpSwap, Bonk, Raydium CPMM, Raydium CLMM - Implement unified event interface (UnifiedEvent trait) and event factory pattern - Add dual streaming support: Yellowstone gRPC and ShredStream - Add Chinese documentation (README_CN.md) 🏗️ Architectural Improvements: - Refactor event parsing system with modular design - Implement protocol-specific parsers and event types - Optimize dependency management, update Cargo.toml - Remove legacy logging modules, clean up redundant code 📊 Statistics: - Added 46 files, 4511 lines of code - Removed 1381 lines of legacy code - Net addition of 3130 lines of code Tech Stack: - Rust async/await for asynchronous processing - Protocol Buffers support - Multi-protocol event parsing - High-performance event stream subscription
This commit is contained in:
Executable
+41
@@ -0,0 +1,41 @@
|
||||
pub mod common;
|
||||
pub mod core;
|
||||
pub mod factory;
|
||||
pub mod protocols;
|
||||
|
||||
pub use core::traits::{EventParser, UnifiedEvent};
|
||||
pub use factory::{EventParserFactory, Protocol};
|
||||
|
||||
/// 宏:简化 downcast_ref 模式匹配
|
||||
///
|
||||
/// # 使用示例
|
||||
/// ```
|
||||
/// use sol_trade_sdk::event_parser::match_event;
|
||||
///
|
||||
/// match_event!(event, {
|
||||
/// PumpSwapCreatePoolEvent => |typed_event| {
|
||||
/// println!("CreatePool event: {:?}", typed_event);
|
||||
/// },
|
||||
/// PumpSwapDepositEvent => |typed_event| {
|
||||
/// // 处理存款事件
|
||||
/// },
|
||||
/// });
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! match_event {
|
||||
($event:expr, {
|
||||
$($event_type:ty => $handler:expr),* $(,)?
|
||||
}) => {
|
||||
$(
|
||||
if let Some(typed_event) = $event.as_any().downcast_ref::<$event_type>() {
|
||||
$handler(typed_event.clone());
|
||||
} else
|
||||
)*
|
||||
{
|
||||
// 默认情况:什么都不做
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// 重新导出宏以便于使用
|
||||
pub use match_event;
|
||||
Reference in New Issue
Block a user