mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-08 22:57:43 +00:00
312a675a40
- Convert UnifiedEvent from trait object (Box<dyn UnifiedEvent>) to concrete enum type - Remove match_event! macro in favor of native match expressions - Simplify event metadata access: event.event_type() -> event.metadata().event_type - Unify event callback signatures: Fn(Box<dyn UnifiedEvent>) -> Fn(UnifiedEvent) - Update all example code to use the new enum-based event system - Optimize type system to reduce runtime overhead and improve type safety Affected scope: - Core event parser and processor - All protocol event definitions (PumpFun, PumpSwap, Bonk, Raydium series, etc.) - gRPC and Shred streaming modules - All example code
38 lines
1.0 KiB
Rust
38 lines
1.0 KiB
Rust
use crate::streaming::event_parser::common::{types::EventType, EventMetadata};
|
|
use borsh::BorshDeserialize;
|
|
use serde::{Deserialize, Serialize};
|
|
use solana_sdk::signature::Signature;
|
|
|
|
/// Block元数据事件
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, BorshDeserialize)]
|
|
pub struct BlockMetaEvent {
|
|
#[borsh(skip)]
|
|
pub metadata: EventMetadata,
|
|
pub slot: u64,
|
|
pub block_hash: String,
|
|
}
|
|
|
|
impl BlockMetaEvent {
|
|
pub fn new(
|
|
slot: u64,
|
|
block_hash: String,
|
|
block_time_ms: i64,
|
|
recv_us: i64,
|
|
) -> Self {
|
|
let metadata = EventMetadata::new(
|
|
Signature::default(),
|
|
slot,
|
|
block_time_ms / 1000,
|
|
block_time_ms,
|
|
crate::streaming::event_parser::common::types::ProtocolType::Common,
|
|
EventType::BlockMeta,
|
|
solana_sdk::pubkey::Pubkey::default(),
|
|
0,
|
|
None,
|
|
recv_us,
|
|
None,
|
|
);
|
|
Self { metadata, slot, block_hash }
|
|
}
|
|
}
|