mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-16 10:28:05 +00:00
perf: Major event processing system refactor for improved performance
This commit is contained in:
@@ -76,10 +76,6 @@ macro_rules! impl_unified_event {
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -323,12 +323,12 @@ impl EventMetadata {
|
||||
instruction_outer_index: i64,
|
||||
instruction_inner_index: Option<i64>,
|
||||
program_received_time_us: i64,
|
||||
transaction_index: Option<u64>,
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
signature,
|
||||
slot,
|
||||
transaction_index: None, // 默认为None,后续设置
|
||||
block_time,
|
||||
block_time_ms,
|
||||
program_received_time_us,
|
||||
@@ -339,6 +339,7 @@ impl EventMetadata {
|
||||
swap_data: None,
|
||||
instruction_outer_index,
|
||||
instruction_inner_index,
|
||||
transaction_index,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,11 +351,6 @@ 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);
|
||||
|
||||
@@ -13,15 +13,6 @@ pub fn extract_discriminator(length: usize, data: &[u8]) -> Option<(&[u8], &[u8]
|
||||
Some((&data[..length], &data[length..]))
|
||||
}
|
||||
|
||||
/// 检查鉴别器是否匹配 - 优化版本
|
||||
pub fn discriminator_matches(data: &str, expected: &str) -> bool {
|
||||
if data.len() < expected.len() {
|
||||
return false;
|
||||
}
|
||||
// 使用字节比较而不是字符串比较,更高效
|
||||
data.as_bytes().starts_with(expected.as_bytes())
|
||||
}
|
||||
|
||||
/// 从日志中提取程序数据
|
||||
pub fn extract_program_data(log: &str) -> Option<&str> {
|
||||
const PROGRAM_DATA_PREFIX: &str = "Program data: ";
|
||||
|
||||
Reference in New Issue
Block a user