diff --git a/Cargo.toml b/Cargo.toml index f53deae..7a7f89d 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-streamer-sdk" -version = "0.4.0" +version = "0.4.1" edition = "2021" authors = ["William ", "sgxiang ", "wei <1415121722@qq.com>"] repository = "https://github.com/0xfnzero/solana-streamer" diff --git a/README.md b/README.md index f45a700..d301572 100755 --- a/README.md +++ b/README.md @@ -46,14 +46,14 @@ Add the dependency to your `Cargo.toml`: ```toml # Add to your Cargo.toml -solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.0" } +solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.1" } ``` ### Use crates.io ```toml # Add to your Cargo.toml -solana-streamer-sdk = "0.4.0" +solana-streamer-sdk = "0.4.1" ``` ## Configuration System diff --git a/README_CN.md b/README_CN.md index a88d3d7..9988650 100644 --- a/README_CN.md +++ b/README_CN.md @@ -45,14 +45,14 @@ git clone https://github.com/0xfnzero/solana-streamer ```toml # 添加到您的 Cargo.toml -solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.0" } +solana-streamer-sdk = { path = "./solana-streamer", version = "0.4.1" } ``` ### 使用 crates.io ```toml # 添加到您的 Cargo.toml -solana-streamer-sdk = "0.4.0" +solana-streamer-sdk = "0.4.1" ``` ## 配置系统 diff --git a/src/main.rs b/src/main.rs index d6ad5c3..5c3fd40 100755 --- a/src/main.rs +++ b/src/main.rs @@ -196,7 +196,7 @@ fn create_event_callback() -> impl Fn(Box) { 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| { diff --git a/src/streaming/common/event_processor.rs b/src/streaming/common/event_processor.rs index c25930f..dbe6517 100644 --- a/src/streaming/common/event_processor.rs +++ b/src/streaming/common/event_processor.rs @@ -94,7 +94,7 @@ impl EventProcessor { let metrics_manager = self.metrics_manager.clone(); Arc::new(move |event: Box| { - 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, &[], diff --git a/src/streaming/event_parser/common/mod.rs b/src/streaming/event_parser/common/mod.rs index 6784e91..92424c6 100755 --- a/src/streaming/event_parser/common/mod.rs +++ b/src/streaming/event_parser/common/mod.rs @@ -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 { - self.metadata.instruction_inner_index + fn inner_index(&self) -> Option { + self.metadata.inner_index } fn transaction_index(&self) -> Option { self.metadata.transaction_index diff --git a/src/streaming/event_parser/common/types.rs b/src/streaming/event_parser/common/types.rs index 877e940..888a088 100755 --- a/src/streaming/event_parser/common/types.rs +++ b/src/streaming/event_parser/common/types.rs @@ -293,14 +293,14 @@ pub struct EventMetadata { pub transaction_index: Option, // 新增:交易在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, - pub instruction_outer_index: i64, - pub instruction_inner_index: Option, + pub outer_index: i64, + pub inner_index: Option, } impl EventMetadata { @@ -313,9 +313,9 @@ impl EventMetadata { protocol: ProtocolType, event_type: EventType, program_id: Pubkey, - instruction_outer_index: i64, - instruction_inner_index: Option, - program_received_time_us: i64, + outer_index: i64, + inner_index: Option, + recv_us: i64, transaction_index: Option, ) -> 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, } } diff --git a/src/streaming/event_parser/core/account_event_parser.rs b/src/streaming/event_parser/core/account_event_parser.rs index 001b263..a9926c5 100644 --- a/src/streaming/event_parser/core/account_event_parser.rs +++ b/src/streaming/event_parser/core/account_event_parser.rs @@ -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); } diff --git a/src/streaming/event_parser/core/common_event_parser.rs b/src/streaming/event_parser/core/common_event_parser.rs index 822d1e8..56f0e8f 100644 --- a/src/streaming/event_parser/core/common_event_parser.rs +++ b/src/streaming/event_parser/core/common_event_parser.rs @@ -8,12 +8,12 @@ impl CommonEventParser { slot: u64, block_hash: String, block_time_ms: i64, - program_received_time_us: i64, + recv_us: i64, ) -> Box { 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) } } diff --git a/src/streaming/event_parser/core/macros.rs b/src/streaming/event_parser/core/macros.rs index 12dd7e2..0216bb7 100644 --- a/src/streaming/event_parser/core/macros.rs +++ b/src/streaming/event_parser/core/macros.rs @@ -30,7 +30,7 @@ macro_rules! impl_event_parser_delegate { signature: solana_sdk::signature::Signature, slot: u64, block_time: Option, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, @@ -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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, config: &GenericEventParseConfig, ) -> Vec> { - 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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, bot_wallet: Option, @@ -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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, bot_wallet: Option, @@ -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 { diff --git a/src/streaming/event_parser/core/traits.rs b/src/streaming/event_parser/core/traits.rs index 8106a78..82ae0fc 100755 --- a/src/streaming/event_parser/core/traits.rs +++ b/src/streaming/event_parser/core/traits.rs @@ -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; + fn outer_index(&self) -> i64; + fn inner_index(&self) -> Option; /// Get transaction index in slot fn transaction_index(&self) -> Option; @@ -285,7 +285,7 @@ pub trait EventParser: Send + Sync { signature: Signature, slot: u64, block_time: Option, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, @@ -300,7 +300,7 @@ pub trait EventParser: Send + Sync { signature: Signature, slot: u64, block_time: Option, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, @@ -316,7 +316,7 @@ pub trait EventParser: Send + Sync { signature: Signature, slot: u64, block_time: Option, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, bot_wallet: Option, @@ -335,7 +335,7 @@ pub trait EventParser: Send + Sync { signature: Signature, slot: u64, block_time: Option, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, bot_wallet: Option, @@ -351,7 +351,7 @@ pub trait EventParser: Send + Sync { signature: Signature, slot: Option, block_time: Option, - program_received_time_us: i64, + recv_us: i64, accounts: &[Pubkey], inner_instructions: &[yellowstone_grpc_proto::prelude::InnerInstructions], bot_wallet: Option, @@ -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, block_time: Option, - program_received_time_us: i64, + recv_us: i64, accounts: &[Pubkey], inner_instructions: &[InnerInstructions], bot_wallet: Option, @@ -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, block_time: Option, - program_received_time_us: i64, + recv_us: i64, bot_wallet: Option, transaction_index: Option, 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, block_time: Option, - program_received_time_us: i64, + recv_us: i64, bot_wallet: Option, transaction_index: Option, 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, block_time: Option, - program_received_time_us: i64, + recv_us: i64, bot_wallet: Option, transaction_index: Option, callback: Arc) + 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, block_time: Option, - program_received_time_us: i64, + recv_us: i64, bot_wallet: Option, transaction_index: Option, callback: Arc Fn(&'a Box) + 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, block_time: Option, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, @@ -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, block_time: Option, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, bot_wallet: Option, @@ -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, block_time: Option, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, bot_wallet: Option, @@ -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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, @@ -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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, @@ -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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, @@ -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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, transaction_index: Option, @@ -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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, bot_wallet: Option, @@ -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, - program_received_time_us: i64, + recv_us: i64, outer_index: i64, inner_index: Option, bot_wallet: Option, @@ -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); diff --git a/src/streaming/event_parser/protocols/block/block_meta_event.rs b/src/streaming/event_parser/protocols/block/block_meta_event.rs index 392e24b..59390ce 100644 --- a/src/streaming/event_parser/protocols/block/block_meta_event.rs +++ b/src/streaming/event_parser/protocols/block/block_meta_event.rs @@ -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 } diff --git a/src/streaming/grpc/pool.rs b/src/streaming/grpc/pool.rs index afc2082..56627c0 100644 --- a/src/streaming/grpc/pool.rs +++ b/src/streaming/grpc/pool.rs @@ -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; } } diff --git a/src/streaming/grpc/types.rs b/src/streaming/grpc/types.rs index 7f2e771..db7fe1c 100644 --- a/src/streaming/grpc/types.rs +++ b/src/streaming/grpc/types.rs @@ -29,7 +29,7 @@ pub struct AccountPretty { pub owner: Pubkey, pub rent_epoch: u64, pub data: Vec, - 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, - 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, 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(), // } // } // } diff --git a/src/streaming/shred/pool.rs b/src/streaming/shred/pool.rs index 07e40df..5dea151 100644 --- a/src/streaming/shred/pool.rs +++ b/src/streaming/shred/pool.rs @@ -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 ) } } diff --git a/src/streaming/shred/types.rs b/src/streaming/shred/types.rs index 7e90d74..ca87cc4 100644 --- a/src/streaming/shred/types.rs +++ b/src/streaming/shred/types.rs @@ -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 } } }