mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-13 00:48:05 +00:00
Merge commit '86b6591b369a220f1a39078ef2a71939d7a2b812' into perf/improve
This commit is contained in:
@@ -69,6 +69,14 @@ macro_rules! impl_unified_event {
|
||||
fn index(&self) -> String {
|
||||
self.metadata.index.clone()
|
||||
}
|
||||
|
||||
fn transaction_index(&self) -> Option<u64> {
|
||||
self.metadata.transaction_index
|
||||
}
|
||||
|
||||
fn set_transaction_index(&mut self, transaction_index: Option<u64>) {
|
||||
self.metadata.set_transaction_index(transaction_index);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -337,6 +337,7 @@ pub struct EventMetadata {
|
||||
pub id: String,
|
||||
pub signature: String,
|
||||
pub slot: u64,
|
||||
pub transaction_index: Option<u64>, // 新增:交易在slot中的索引
|
||||
pub block_time: i64,
|
||||
pub block_time_ms: i64,
|
||||
pub program_received_time_us: i64,
|
||||
@@ -347,7 +348,7 @@ pub struct EventMetadata {
|
||||
#[deprecated(note = "Please use swap_data instead")]
|
||||
pub transfer_datas: Vec<TransferData>,
|
||||
pub swap_data: Option<SwapData>,
|
||||
pub index: String,
|
||||
pub index: String, // 保留原有的指令索引
|
||||
}
|
||||
|
||||
impl EventMetadata {
|
||||
@@ -368,6 +369,7 @@ impl EventMetadata {
|
||||
id,
|
||||
signature,
|
||||
slot,
|
||||
transaction_index: None, // 默认为None,后续设置
|
||||
block_time,
|
||||
block_time_ms,
|
||||
program_received_time_us,
|
||||
@@ -389,6 +391,11 @@ impl EventMetadata {
|
||||
self.swap_data = Some(swap_data);
|
||||
}
|
||||
|
||||
/// 设置交易索引
|
||||
pub fn set_transaction_index(&mut self, transaction_index: Option<u64>) {
|
||||
self.transaction_index = transaction_index;
|
||||
}
|
||||
|
||||
/// Recycle EventMetadata to object pool
|
||||
pub fn recycle(self) {
|
||||
EVENT_METADATA_POOL.release(self);
|
||||
|
||||
@@ -64,6 +64,12 @@ pub trait UnifiedEvent: Debug + Send + Sync {
|
||||
|
||||
/// Get index
|
||||
fn index(&self) -> String;
|
||||
|
||||
/// Get transaction index in slot
|
||||
fn transaction_index(&self) -> Option<u64>;
|
||||
|
||||
/// Set transaction index in slot
|
||||
fn set_transaction_index(&mut self, transaction_index: Option<u64>);
|
||||
}
|
||||
|
||||
/// 事件解析器trait - 定义了事件解析的核心方法
|
||||
|
||||
Reference in New Issue
Block a user