refactor: simplify event API method names for better ergonomics

- Rename verbose method names to shorter, clearer alternatives
- program_received_time_us() → recv_us()
- program_handle_time_consuming_us() → handle_us()
- instruction_outer_index() → outer_index()
- instruction_inner_index() → inner_index()
- Update all implementations across event parsers and processors

Improves developer experience while maintaining semantic clarity.
This commit is contained in:
ysq
2025-09-03 15:49:50 +08:00
parent 7601eb370c
commit 1060b04b12
16 changed files with 122 additions and 122 deletions
+10 -10
View File
@@ -20,16 +20,16 @@ macro_rules! impl_unified_event {
self.metadata.slot
}
fn program_received_time_us(&self) -> i64 {
self.metadata.program_received_time_us
fn recv_us(&self) -> i64 {
self.metadata.recv_us
}
fn program_handle_time_consuming_us(&self) -> i64 {
self.metadata.program_handle_time_consuming_us
fn handle_us(&self) -> i64 {
self.metadata.handle_us
}
fn set_program_handle_time_consuming_us(&mut self, program_handle_time_consuming_us: i64) {
self.metadata.program_handle_time_consuming_us = program_handle_time_consuming_us;
fn set_handle_us(&mut self, handle_us: i64) {
self.metadata.handle_us = handle_us;
}
fn as_any(&self) -> &dyn std::any::Any {
@@ -60,12 +60,12 @@ macro_rules! impl_unified_event {
self.metadata.swap_data.is_some()
}
fn instruction_outer_index(&self) -> i64 {
self.metadata.instruction_outer_index
fn outer_index(&self) -> i64 {
self.metadata.outer_index
}
fn instruction_inner_index(&self) -> Option<i64> {
self.metadata.instruction_inner_index
fn inner_index(&self) -> Option<i64> {
self.metadata.inner_index
}
fn transaction_index(&self) -> Option<u64> {
self.metadata.transaction_index
+11 -11
View File
@@ -293,14 +293,14 @@ pub struct EventMetadata {
pub transaction_index: Option<u64>, // 新增:交易在slot中的索引
pub block_time: i64,
pub block_time_ms: i64,
pub program_received_time_us: i64,
pub program_handle_time_consuming_us: i64,
pub recv_us: i64,
pub handle_us: i64,
pub protocol: ProtocolType,
pub event_type: EventType,
pub program_id: Pubkey,
pub swap_data: Option<SwapData>,
pub instruction_outer_index: i64,
pub instruction_inner_index: Option<i64>,
pub outer_index: i64,
pub inner_index: Option<i64>,
}
impl EventMetadata {
@@ -313,9 +313,9 @@ impl EventMetadata {
protocol: ProtocolType,
event_type: EventType,
program_id: Pubkey,
instruction_outer_index: i64,
instruction_inner_index: Option<i64>,
program_received_time_us: i64,
outer_index: i64,
inner_index: Option<i64>,
recv_us: i64,
transaction_index: Option<u64>,
) -> Self {
Self {
@@ -323,14 +323,14 @@ impl EventMetadata {
slot,
block_time,
block_time_ms,
program_received_time_us,
program_handle_time_consuming_us: 0,
recv_us,
handle_us: 0,
protocol,
event_type,
program_id,
swap_data: None,
instruction_outer_index,
instruction_inner_index,
outer_index,
inner_index,
transaction_index,
}
}