feat: refactor shred streaming with modular architecture

This commit is contained in:
ysq
2025-08-18 01:08:12 +08:00
parent ea7ecd1d0c
commit a9ceaa55d3
13 changed files with 583 additions and 528 deletions
+10 -3
View File
@@ -43,7 +43,7 @@ use solana_streamer_sdk::{
Protocol, UnifiedEvent,
},
grpc::ClientConfig,
shred_stream::ShredClientConfig,
shred::StreamClientConfig,
yellowstone_grpc::{AccountFilter, TransactionFilter},
ShredStreamGrpc, YellowstoneGrpc,
},
@@ -137,7 +137,7 @@ async fn test_shreds() -> Result<(), Box<dyn std::error::Error>> {
println!("Subscribing to ShredStream events...");
// Create low-latency configuration
let mut config = ShredClientConfig::low_latency();
let mut config = StreamClientConfig::low_latency();
// Enable performance monitoring, has performance overhead, disabled by default
config.enable_metrics = true;
let shred_stream =
@@ -153,8 +153,15 @@ async fn test_shreds() -> Result<(), Box<dyn std::error::Error>> {
Protocol::RaydiumAmmV4,
];
// Event filtering
// No event filtering, includes all events
let event_type_filter = None;
// Only include PumpSwapBuy events and PumpSwapSell events
// let event_type_filter =
// EventTypeFilter { include: vec![EventType::PumpSwapBuy, EventType::PumpSwapSell] };
println!("Listening for events, press Ctrl+C to stop...");
shred_stream.shredstream_subscribe(protocols, None, callback).await?;
shred_stream.shredstream_subscribe(protocols, None, event_type_filter, callback).await?;
Ok(())
}