2025-08-11 01:04:16 +08:00
|
|
|
use crate::impl_unified_event;
|
|
|
|
|
use crate::streaming::event_parser::common::{types::EventType, EventMetadata};
|
|
|
|
|
use borsh::BorshDeserialize;
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
2025-09-02 17:27:27 +08:00
|
|
|
use solana_sdk::signature::Signature;
|
2025-08-11 01:04:16 +08:00
|
|
|
|
|
|
|
|
/// 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 {
|
2025-08-26 17:57:39 +08:00
|
|
|
pub fn new(
|
|
|
|
|
slot: u64,
|
|
|
|
|
block_hash: String,
|
|
|
|
|
block_time_ms: i64,
|
|
|
|
|
program_received_time_us: i64,
|
|
|
|
|
) -> Self {
|
2025-08-11 01:04:16 +08:00
|
|
|
let metadata = EventMetadata::new(
|
2025-09-02 17:27:27 +08:00
|
|
|
Signature::default(),
|
2025-08-11 01:04:16 +08:00
|
|
|
slot,
|
|
|
|
|
block_time_ms / 1000,
|
|
|
|
|
block_time_ms,
|
|
|
|
|
crate::streaming::event_parser::common::types::ProtocolType::Common,
|
|
|
|
|
EventType::BlockMeta,
|
|
|
|
|
solana_sdk::pubkey::Pubkey::default(),
|
2025-08-27 21:31:31 +08:00
|
|
|
0,
|
|
|
|
|
None,
|
2025-08-26 17:57:39 +08:00
|
|
|
program_received_time_us,
|
2025-08-28 14:49:56 +08:00
|
|
|
None,
|
2025-08-11 01:04:16 +08:00
|
|
|
);
|
|
|
|
|
Self { metadata, slot, block_hash }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 使用macro生成UnifiedEvent实现
|
|
|
|
|
impl_unified_event!(BlockMetaEvent,);
|