mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-17 10:58:06 +00:00
feat: enhance event filtering and monitoring system
- Add EventTypeFilter for precise event type filtering - Refactor metrics to track events by type (tx/account/block) - Add parser caching for improved performance - Enhance gRPC subscription management - Update examples and type definitions
This commit is contained in:
+10
-2
@@ -2,6 +2,7 @@ use solana_streamer_sdk::{
|
||||
match_event,
|
||||
streaming::{
|
||||
event_parser::{
|
||||
common::{filter::EventTypeFilter, EventType},
|
||||
protocols::{
|
||||
bonk::{
|
||||
parser::BONK_PROGRAM_ID, BonkGlobalConfigAccountEvent, BonkMigrateToAmmEvent,
|
||||
@@ -97,16 +98,22 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let account_exclude = vec![];
|
||||
let account_required = vec![];
|
||||
|
||||
// 监听交易数据
|
||||
// Listen to transaction data
|
||||
let transaction_filter = TransactionFilter {
|
||||
account_include: account_include.clone(),
|
||||
account_exclude,
|
||||
account_required,
|
||||
};
|
||||
|
||||
// 监听属于owner程序的账号数据 -> 账号事件监听
|
||||
// Listen to account data belonging to owner programs -> account event monitoring
|
||||
let account_filter = AccountFilter { account: vec![], owner: account_include.clone() };
|
||||
|
||||
// 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!("Starting to listen for events, press Ctrl+C to stop...");
|
||||
println!("Monitoring programs: {:?}", account_include);
|
||||
|
||||
@@ -117,6 +124,7 @@ async fn test_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
||||
None,
|
||||
transaction_filter,
|
||||
account_filter,
|
||||
event_type_filter,
|
||||
None,
|
||||
callback,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user