mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-15 18:08:05 +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:
@@ -0,0 +1,24 @@
|
||||
use crate::streaming::event_parser::common::{
|
||||
types::EventType, ACCOUNT_EVENT_TYPES, BLOCK_EVENT_TYPES,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct EventTypeFilter {
|
||||
pub include: Vec<EventType>,
|
||||
}
|
||||
|
||||
impl EventTypeFilter {
|
||||
pub fn include_transaction_event(&self) -> bool {
|
||||
self.include
|
||||
.iter()
|
||||
.any(|event| !ACCOUNT_EVENT_TYPES.contains(event) && !BLOCK_EVENT_TYPES.contains(event))
|
||||
}
|
||||
|
||||
pub fn include_account_event(&self) -> bool {
|
||||
self.include.iter().any(|event| ACCOUNT_EVENT_TYPES.contains(event))
|
||||
}
|
||||
|
||||
pub fn include_block_event(&self) -> bool {
|
||||
self.include.iter().any(|event| BLOCK_EVENT_TYPES.contains(event))
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod types;
|
||||
pub mod utils;
|
||||
pub mod filter;
|
||||
|
||||
/// 自动生成UnifiedEvent trait实现的宏
|
||||
#[macro_export]
|
||||
|
||||
@@ -180,6 +180,24 @@ pub enum EventType {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
pub const ACCOUNT_EVENT_TYPES: &[EventType] = &[
|
||||
EventType::AccountRaydiumAmmV4AmmInfo,
|
||||
EventType::AccountPumpSwapGlobalConfig,
|
||||
EventType::AccountPumpSwapPool,
|
||||
EventType::AccountBonkPoolState,
|
||||
EventType::AccountBonkGlobalConfig,
|
||||
EventType::AccountBonkPlatformConfig,
|
||||
EventType::AccountBonkVestingRecord,
|
||||
EventType::AccountPumpFunBondingCurve,
|
||||
EventType::AccountPumpFunGlobal,
|
||||
EventType::AccountRaydiumClmmAmmConfig,
|
||||
EventType::AccountRaydiumClmmPoolState,
|
||||
EventType::AccountRaydiumClmmTickArrayState,
|
||||
EventType::AccountRaydiumCpmmAmmConfig,
|
||||
EventType::AccountRaydiumCpmmPoolState,
|
||||
];
|
||||
pub const BLOCK_EVENT_TYPES: &[EventType] = &[EventType::BlockMeta];
|
||||
|
||||
impl EventType {
|
||||
#[allow(clippy::inherent_to_string)]
|
||||
pub fn to_string(&self) -> String {
|
||||
|
||||
Reference in New Issue
Block a user