mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-14 09:28:05 +00:00
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:
+1
-1
@@ -196,7 +196,7 @@ fn create_event_callback() -> impl Fn(Box<dyn UnifiedEvent>) {
|
||||
match_event!(event, {
|
||||
// -------------------------- block meta -----------------------
|
||||
BlockMetaEvent => |e: BlockMetaEvent| {
|
||||
println!("BlockMetaEvent: {:?}", e.metadata.program_handle_time_consuming_us);
|
||||
println!("BlockMetaEvent: {:?}", e.metadata.handle_us);
|
||||
},
|
||||
// -------------------------- bonk -----------------------
|
||||
BonkPoolCreateEvent => |e: BonkPoolCreateEvent| {
|
||||
|
||||
@@ -94,7 +94,7 @@ impl EventProcessor {
|
||||
let metrics_manager = self.metrics_manager.clone();
|
||||
|
||||
Arc::new(move |event: Box<dyn UnifiedEvent>| {
|
||||
let processing_time_us = event.program_handle_time_consuming_us() as f64;
|
||||
let processing_time_us = event.handle_us() as f64;
|
||||
callback(event);
|
||||
metrics_manager.update_metrics(MetricsEventType::Transaction, 1, processing_time_us);
|
||||
})
|
||||
@@ -171,7 +171,7 @@ impl EventProcessor {
|
||||
self.event_type_filter.as_ref(),
|
||||
);
|
||||
if let Some(event) = account_event {
|
||||
let processing_time_us = event.program_handle_time_consuming_us() as f64;
|
||||
let processing_time_us = event.handle_us() as f64;
|
||||
self.invoke_callback(event);
|
||||
self.update_metrics(MetricsEventType::Account, 1, processing_time_us);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ impl EventProcessor {
|
||||
let slot = transaction_pretty.slot;
|
||||
let signature = transaction_pretty.signature;
|
||||
let block_time = transaction_pretty.block_time;
|
||||
let program_received_time_us = transaction_pretty.program_received_time_us;
|
||||
let recv_us = transaction_pretty.recv_us;
|
||||
let transaction_index = transaction_pretty.transaction_index;
|
||||
let grpc_tx = transaction_pretty.grpc_tx;
|
||||
|
||||
@@ -193,7 +193,7 @@ impl EventProcessor {
|
||||
signature,
|
||||
Some(slot),
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
bot_wallet,
|
||||
transaction_index,
|
||||
adapter_callback,
|
||||
@@ -210,9 +210,9 @@ impl EventProcessor {
|
||||
block_meta_pretty.slot,
|
||||
block_meta_pretty.block_hash,
|
||||
block_time_ms,
|
||||
block_meta_pretty.program_received_time_us,
|
||||
block_meta_pretty.recv_us,
|
||||
);
|
||||
let processing_time_us = block_meta_event.program_handle_time_consuming_us() as f64;
|
||||
let processing_time_us = block_meta_event.handle_us() as f64;
|
||||
self.invoke_callback(block_meta_event);
|
||||
self.update_metrics(MetricsEventType::BlockMeta, 1, processing_time_us);
|
||||
}
|
||||
@@ -302,7 +302,7 @@ impl EventProcessor {
|
||||
|
||||
let slot = transaction_with_slot.slot;
|
||||
let signature = tx.signatures[0];
|
||||
let program_received_time_us = transaction_with_slot.program_received_time_us;
|
||||
let recv_us = transaction_with_slot.recv_us;
|
||||
|
||||
let parser = self.get_parser();
|
||||
let adapter_callback = self.create_adapter_callback();
|
||||
@@ -312,7 +312,7 @@ impl EventProcessor {
|
||||
signature,
|
||||
Some(slot),
|
||||
None,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
bot_wallet,
|
||||
None,
|
||||
&[],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,13 +184,13 @@ impl AccountEventParser {
|
||||
protocol: config.protocol_type,
|
||||
event_type: config.event_type,
|
||||
program_id: config.program_id,
|
||||
program_received_time_us: account.program_received_time_us,
|
||||
recv_us: account.recv_us,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
if let Some(mut event) = event {
|
||||
event.set_program_handle_time_consuming_us(elapsed_micros_since(
|
||||
account.program_received_time_us,
|
||||
event.set_handle_us(elapsed_micros_since(
|
||||
account.recv_us,
|
||||
));
|
||||
return Some(event);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ impl CommonEventParser {
|
||||
slot: u64,
|
||||
block_hash: String,
|
||||
block_time_ms: i64,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
) -> Box<dyn UnifiedEvent> {
|
||||
let mut block_meta_event =
|
||||
BlockMetaEvent::new(slot, block_hash, block_time_ms, program_received_time_us);
|
||||
BlockMetaEvent::new(slot, block_hash, block_time_ms, recv_us);
|
||||
block_meta_event
|
||||
.set_program_handle_time_consuming_us(elapsed_micros_since(program_received_time_us));
|
||||
.set_handle_us(elapsed_micros_since(recv_us));
|
||||
Box::new(block_meta_event)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ macro_rules! impl_event_parser_delegate {
|
||||
signature: solana_sdk::signature::Signature,
|
||||
slot: u64,
|
||||
block_time: Option<prost_types::Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
@@ -41,7 +41,7 @@ macro_rules! impl_event_parser_delegate {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
transaction_index,
|
||||
@@ -55,13 +55,13 @@ macro_rules! impl_event_parser_delegate {
|
||||
signature: solana_sdk::signature::Signature,
|
||||
slot: u64,
|
||||
block_time: Option<prost_types::Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
config: &GenericEventParseConfig,
|
||||
) -> Vec<Box<dyn $crate::streaming::event_parser::core::traits::UnifiedEvent>> {
|
||||
self.inner.parse_events_from_grpc_inner_instruction(inner_instruction, signature, slot, block_time, program_received_time_us, outer_index, inner_index, transaction_index, config)
|
||||
self.inner.parse_events_from_grpc_inner_instruction(inner_instruction, signature, slot, block_time, recv_us, outer_index, inner_index, transaction_index, config)
|
||||
}
|
||||
|
||||
fn parse_events_from_instruction(
|
||||
@@ -71,7 +71,7 @@ macro_rules! impl_event_parser_delegate {
|
||||
signature: solana_sdk::signature::Signature,
|
||||
slot: u64,
|
||||
block_time: Option<prost_types::Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<solana_sdk::pubkey::Pubkey>,
|
||||
@@ -89,7 +89,7 @@ macro_rules! impl_event_parser_delegate {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
bot_wallet,
|
||||
@@ -106,7 +106,7 @@ macro_rules! impl_event_parser_delegate {
|
||||
signature: solana_sdk::signature::Signature,
|
||||
slot: u64,
|
||||
block_time: Option<prost_types::Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<solana_sdk::pubkey::Pubkey>,
|
||||
@@ -118,7 +118,7 @@ macro_rules! impl_event_parser_delegate {
|
||||
+ Sync,
|
||||
>,
|
||||
) -> anyhow::Result<()> {
|
||||
self.inner.parse_events_from_grpc_instruction(instruction, accounts, signature, slot, block_time, program_received_time_us, outer_index, inner_index, bot_wallet, transaction_index, inner_instructions, callback)
|
||||
self.inner.parse_events_from_grpc_instruction(instruction, accounts, signature, slot, block_time, recv_us, outer_index, inner_index, bot_wallet, transaction_index, inner_instructions, callback)
|
||||
}
|
||||
|
||||
fn should_handle(&self, program_id: &solana_sdk::pubkey::Pubkey) -> bool {
|
||||
|
||||
@@ -236,13 +236,13 @@ pub trait UnifiedEvent: Debug + Send + Sync {
|
||||
fn slot(&self) -> u64;
|
||||
|
||||
/// Get program received timestamp (milliseconds)
|
||||
fn program_received_time_us(&self) -> i64;
|
||||
fn recv_us(&self) -> i64;
|
||||
|
||||
/// Processing time consumption (milliseconds)
|
||||
fn program_handle_time_consuming_us(&self) -> i64;
|
||||
fn handle_us(&self) -> i64;
|
||||
|
||||
/// Set processing time consumption (milliseconds)
|
||||
fn set_program_handle_time_consuming_us(&mut self, program_handle_time_consuming_us: i64);
|
||||
fn set_handle_us(&mut self, handle_us: i64);
|
||||
|
||||
/// Convert event to Any for downcasting
|
||||
fn as_any(&self) -> &dyn std::any::Any;
|
||||
@@ -265,8 +265,8 @@ pub trait UnifiedEvent: Debug + Send + Sync {
|
||||
fn swap_data_is_parsed(&self) -> bool;
|
||||
|
||||
/// Get index
|
||||
fn instruction_outer_index(&self) -> i64;
|
||||
fn instruction_inner_index(&self) -> Option<i64>;
|
||||
fn outer_index(&self) -> i64;
|
||||
fn inner_index(&self) -> Option<i64>;
|
||||
|
||||
/// Get transaction index in slot
|
||||
fn transaction_index(&self) -> Option<u64>;
|
||||
@@ -285,7 +285,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
@@ -300,7 +300,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
@@ -316,7 +316,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
@@ -335,7 +335,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
@@ -351,7 +351,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
accounts: &[Pubkey],
|
||||
inner_instructions: &[yellowstone_grpc_proto::prelude::InnerInstructions],
|
||||
bot_wallet: Option<Pubkey>,
|
||||
@@ -383,7 +383,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
index as i64,
|
||||
None,
|
||||
bot_wallet,
|
||||
@@ -407,7 +407,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
accounts: &[Pubkey],
|
||||
inner_instructions: &[InnerInstructions],
|
||||
bot_wallet: Option<Pubkey>,
|
||||
@@ -440,7 +440,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
index as i64,
|
||||
None,
|
||||
bot_wallet,
|
||||
@@ -462,7 +462,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
transaction_index: Option<u64>,
|
||||
inner_instructions: &[InnerInstructions],
|
||||
@@ -477,7 +477,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
bot_wallet,
|
||||
transaction_index,
|
||||
inner_instructions,
|
||||
@@ -493,7 +493,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
transaction_index: Option<u64>,
|
||||
inner_instructions: &[InnerInstructions],
|
||||
@@ -505,7 +505,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
&accounts,
|
||||
inner_instructions,
|
||||
bot_wallet,
|
||||
@@ -522,7 +522,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
transaction_index: Option<u64>,
|
||||
callback: Arc<dyn Fn(Box<dyn UnifiedEvent>) + Send + Sync>,
|
||||
@@ -537,7 +537,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
bot_wallet,
|
||||
transaction_index,
|
||||
adapter_callback,
|
||||
@@ -551,7 +551,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
transaction_index: Option<u64>,
|
||||
callback: Arc<dyn for<'a> Fn(&'a Box<dyn UnifiedEvent>) + Send + Sync>,
|
||||
@@ -600,7 +600,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
&accounts_arc,
|
||||
&inner_instructions_arc,
|
||||
bot_wallet,
|
||||
@@ -625,7 +625,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
inner_instruction.index as i64,
|
||||
Some(index as i64),
|
||||
bot_wallet,
|
||||
@@ -732,7 +732,7 @@ pub trait EventParser: Send + Sync {
|
||||
|
||||
let slot = transaction.slot;
|
||||
let block_time = transaction.block_time.map(|t| Timestamp { seconds: t as i64, nanos: 0 });
|
||||
let program_received_time_us = get_high_perf_clock();
|
||||
let recv_us = get_high_perf_clock();
|
||||
let bot_wallet = None;
|
||||
let transaction_index = None;
|
||||
// 解析指令事件
|
||||
@@ -741,7 +741,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
Some(slot),
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
&accounts_arc,
|
||||
&inner_instructions_arc,
|
||||
bot_wallet,
|
||||
@@ -759,7 +759,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
Some(slot),
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
inner_instruction.index as i64,
|
||||
Some(index as i64),
|
||||
bot_wallet,
|
||||
@@ -780,7 +780,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
@@ -792,7 +792,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
transaction_index,
|
||||
@@ -809,7 +809,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
@@ -824,7 +824,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
bot_wallet,
|
||||
@@ -842,7 +842,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature: Signature,
|
||||
slot: Option<u64>,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
@@ -857,7 +857,7 @@ pub trait EventParser: Send + Sync {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
bot_wallet,
|
||||
@@ -938,7 +938,7 @@ impl GenericEventParser {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
@@ -956,7 +956,7 @@ impl GenericEventParser {
|
||||
config.program_id,
|
||||
outer_index,
|
||||
inner_index,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
transaction_index,
|
||||
);
|
||||
parser(data, metadata)
|
||||
@@ -975,7 +975,7 @@ impl GenericEventParser {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
@@ -993,7 +993,7 @@ impl GenericEventParser {
|
||||
config.program_id,
|
||||
outer_index,
|
||||
inner_index,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
transaction_index,
|
||||
);
|
||||
parser(data, account_pubkeys, metadata)
|
||||
@@ -1016,7 +1016,7 @@ impl EventParser for GenericEventParser {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
@@ -1034,7 +1034,7 @@ impl EventParser for GenericEventParser {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
transaction_index,
|
||||
@@ -1052,7 +1052,7 @@ impl EventParser for GenericEventParser {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
transaction_index: Option<u64>,
|
||||
@@ -1070,7 +1070,7 @@ impl EventParser for GenericEventParser {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
transaction_index,
|
||||
@@ -1089,7 +1089,7 @@ impl EventParser for GenericEventParser {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
@@ -1141,7 +1141,7 @@ impl EventParser for GenericEventParser {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
transaction_index,
|
||||
@@ -1165,7 +1165,7 @@ impl EventParser for GenericEventParser {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
transaction_index,
|
||||
@@ -1205,8 +1205,8 @@ impl EventParser for GenericEventParser {
|
||||
event.merge(&*inner_instruction_event);
|
||||
}
|
||||
// 设置处理时间(使用高性能时钟)
|
||||
event.set_program_handle_time_consuming_us(elapsed_micros_since(
|
||||
program_received_time_us,
|
||||
event.set_handle_us(elapsed_micros_since(
|
||||
recv_us,
|
||||
));
|
||||
event = process_event(event, bot_wallet);
|
||||
callback(&event);
|
||||
@@ -1224,7 +1224,7 @@ impl EventParser for GenericEventParser {
|
||||
signature: Signature,
|
||||
slot: u64,
|
||||
block_time: Option<Timestamp>,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
outer_index: i64,
|
||||
inner_index: Option<i64>,
|
||||
bot_wallet: Option<Pubkey>,
|
||||
@@ -1276,7 +1276,7 @@ impl EventParser for GenericEventParser {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
transaction_index,
|
||||
@@ -1300,7 +1300,7 @@ impl EventParser for GenericEventParser {
|
||||
signature,
|
||||
slot,
|
||||
block_time,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
outer_index,
|
||||
inner_index,
|
||||
transaction_index,
|
||||
@@ -1340,8 +1340,8 @@ impl EventParser for GenericEventParser {
|
||||
event.merge(&*inner_instruction_event);
|
||||
}
|
||||
// 设置处理时间(使用高性能时钟)
|
||||
event.set_program_handle_time_consuming_us(elapsed_micros_since(
|
||||
program_received_time_us,
|
||||
event.set_handle_us(elapsed_micros_since(
|
||||
recv_us,
|
||||
));
|
||||
event = process_event(event, bot_wallet);
|
||||
callback(&event);
|
||||
|
||||
@@ -18,7 +18,7 @@ impl BlockMetaEvent {
|
||||
slot: u64,
|
||||
block_hash: String,
|
||||
block_time_ms: i64,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
) -> Self {
|
||||
let metadata = EventMetadata::new(
|
||||
Signature::default(),
|
||||
@@ -30,7 +30,7 @@ impl BlockMetaEvent {
|
||||
solana_sdk::pubkey::Pubkey::default(),
|
||||
0,
|
||||
None,
|
||||
program_received_time_us,
|
||||
recv_us,
|
||||
None,
|
||||
);
|
||||
Self { metadata, slot, block_hash }
|
||||
|
||||
@@ -118,7 +118,7 @@ impl PooledAccountPretty {
|
||||
self.account.data = new_data;
|
||||
}
|
||||
|
||||
self.account.program_received_time_us = get_high_perf_clock();
|
||||
self.account.recv_us = get_high_perf_clock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ impl PooledBlockMetaPretty {
|
||||
self.block_meta.slot = block_update.slot;
|
||||
self.block_meta.block_hash = block_update.blockhash;
|
||||
self.block_meta.block_time = block_time;
|
||||
self.block_meta.program_received_time_us = get_high_perf_clock();
|
||||
self.block_meta.recv_us = get_high_perf_clock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ impl PooledTransactionPretty {
|
||||
self.transaction.signature =
|
||||
Signature::try_from(tx.signature.as_slice()).expect("valid signature");
|
||||
self.transaction.is_vote = tx.is_vote;
|
||||
self.transaction.program_received_time_us = get_high_perf_clock();
|
||||
self.transaction.recv_us = get_high_perf_clock();
|
||||
self.transaction.grpc_tx = tx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ pub struct AccountPretty {
|
||||
pub owner: Pubkey,
|
||||
pub rent_epoch: u64,
|
||||
pub data: Vec<u8>,
|
||||
pub program_received_time_us: i64,
|
||||
pub recv_us: i64,
|
||||
}
|
||||
|
||||
impl fmt::Debug for AccountPretty {
|
||||
@@ -52,7 +52,7 @@ pub struct BlockMetaPretty {
|
||||
pub slot: u64,
|
||||
pub block_hash: String,
|
||||
pub block_time: Option<Timestamp>,
|
||||
pub program_received_time_us: i64,
|
||||
pub recv_us: i64,
|
||||
}
|
||||
|
||||
impl fmt::Debug for BlockMetaPretty {
|
||||
@@ -61,7 +61,7 @@ impl fmt::Debug for BlockMetaPretty {
|
||||
.field("slot", &self.slot)
|
||||
.field("block_hash", &self.block_hash)
|
||||
.field("block_time", &self.block_time)
|
||||
.field("program_received_time_us", &self.program_received_time_us)
|
||||
.field("recv_us", &self.recv_us)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ pub struct TransactionPretty {
|
||||
pub block_time: Option<Timestamp>,
|
||||
pub signature: Signature,
|
||||
pub is_vote: bool,
|
||||
pub program_received_time_us: i64,
|
||||
pub recv_us: i64,
|
||||
pub grpc_tx: SubscribeUpdateTransactionInfo,
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ impl fmt::Debug for TransactionPretty {
|
||||
.field("transaction_index", &self.transaction_index)
|
||||
.field("signature", &self.signature)
|
||||
.field("is_vote", &self.is_vote)
|
||||
.field("program_received_time_us", &self.program_received_time_us)
|
||||
.field("recv_us", &self.recv_us)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ impl Default for TransactionPretty {
|
||||
signature: Signature::default(),
|
||||
is_vote: false,
|
||||
grpc_tx: SubscribeUpdateTransactionInfo::default(),
|
||||
program_received_time_us: 0,
|
||||
recv_us: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ impl Default for TransactionPretty {
|
||||
// owner: Pubkey::try_from(account_info.owner.as_slice()).expect("valid pubkey"),
|
||||
// rent_epoch: account_info.rent_epoch,
|
||||
// data: account_info.data,
|
||||
// program_received_time_us: get_high_perf_clock(),
|
||||
// recv_us: get_high_perf_clock(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -137,7 +137,7 @@ impl Default for TransactionPretty {
|
||||
// block_hash: blockhash,
|
||||
// block_time,
|
||||
// slot,
|
||||
// program_received_time_us: get_high_perf_clock(),
|
||||
// recv_us: get_high_perf_clock(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -161,7 +161,7 @@ impl Default for TransactionPretty {
|
||||
// is_vote: tx.is_vote,
|
||||
// tx: yellowstone_grpc_proto::convert_from::create_tx_with_meta(tx)
|
||||
// .expect("valid tx with meta"),
|
||||
// program_received_time_us: get_high_perf_clock(),
|
||||
// recv_us: get_high_perf_clock(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -52,11 +52,11 @@ impl PooledTransactionWithSlot {
|
||||
&mut self,
|
||||
transaction: VersionedTransaction,
|
||||
slot: u64,
|
||||
program_received_time_us: i64
|
||||
recv_us: i64
|
||||
) {
|
||||
self.transaction.transaction = transaction;
|
||||
self.transaction.slot = slot;
|
||||
self.transaction.program_received_time_us = program_received_time_us;
|
||||
self.transaction.recv_us = recv_us;
|
||||
}
|
||||
|
||||
/// 使用优化的工厂方法创建 TransactionWithSlot(移动数据而不是克隆)
|
||||
@@ -72,7 +72,7 @@ impl Drop for PooledTransactionWithSlot {
|
||||
if pool.len() < self.max_size {
|
||||
// 清理敏感数据
|
||||
self.transaction.slot = 0;
|
||||
self.transaction.program_received_time_us = 0;
|
||||
self.transaction.recv_us = 0;
|
||||
// 重置交易为默认值以清理敏感数据
|
||||
self.transaction.transaction = VersionedTransaction::default();
|
||||
pool.push_back(std::mem::take(&mut self.transaction));
|
||||
@@ -118,10 +118,10 @@ impl ShredPoolManager {
|
||||
&self,
|
||||
transaction: VersionedTransaction,
|
||||
slot: u64,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
) -> TransactionWithSlot {
|
||||
let mut pooled_tx = self.transaction_pool.acquire();
|
||||
pooled_tx.reset_from_data(transaction, slot, program_received_time_us);
|
||||
pooled_tx.reset_from_data(transaction, slot, recv_us);
|
||||
pooled_tx.into_transaction_with_slot()
|
||||
}
|
||||
}
|
||||
@@ -145,12 +145,12 @@ pub mod factory {
|
||||
pub fn create_transaction_with_slot_pooled(
|
||||
transaction: VersionedTransaction,
|
||||
slot: u64,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
) -> TransactionWithSlot {
|
||||
GLOBAL_SHRED_POOL_MANAGER.create_transaction_with_slot_optimized(
|
||||
transaction,
|
||||
slot,
|
||||
program_received_time_us
|
||||
recv_us
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use solana_sdk::transaction::VersionedTransaction;
|
||||
pub struct TransactionWithSlot {
|
||||
pub transaction: VersionedTransaction,
|
||||
pub slot: u64,
|
||||
pub program_received_time_us: i64,
|
||||
pub recv_us: i64,
|
||||
}
|
||||
|
||||
impl TransactionWithSlot {
|
||||
@@ -13,8 +13,8 @@ impl TransactionWithSlot {
|
||||
pub fn new(
|
||||
transaction: VersionedTransaction,
|
||||
slot: u64,
|
||||
program_received_time_us: i64,
|
||||
recv_us: i64,
|
||||
) -> Self {
|
||||
Self { transaction, slot, program_received_time_us }
|
||||
Self { transaction, slot, recv_us }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user