From 7c43af9388b9d800e56f1ec0fd24de017450e1d7 Mon Sep 17 00:00:00 2001 From: Dana Date: Fri, 4 Aug 2023 17:39:36 -0600 Subject: [PATCH] add block_time to all messages --- crates/plugin/src/convert.rs | 2 ++ crates/plugin/src/plugin.rs | 1 + crates/plugin/src/stats.rs | 2 +- crates/rabbitmq/src/geyser.rs | 20 ++++++++++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/plugin/src/convert.rs b/crates/plugin/src/convert.rs index 2b18f57..5d60512 100644 --- a/crates/plugin/src/convert.rs +++ b/crates/plugin/src/convert.rs @@ -19,6 +19,7 @@ pub fn create_account_update( is_startup, txn_signature: None, write_version: account.write_version, + block_time: 0, }, ReplicaAccountInfoVersions::V0_0_2(account) => AccountUpdate { key: Pubkey::new_from_array(account.pubkey.try_into().unwrap()), @@ -31,6 +32,7 @@ pub fn create_account_update( is_startup, txn_signature: account.txn_signature.map(std::string::ToString::to_string), write_version: account.write_version, + block_time: 0, }, } } diff --git a/crates/plugin/src/plugin.rs b/crates/plugin/src/plugin.rs index a07629a..0ea71dd 100644 --- a/crates/plugin/src/plugin.rs +++ b/crates/plugin/src/plugin.rs @@ -312,6 +312,7 @@ impl GeyserPlugin for GeyserPluginRabbitMq { data, accounts, slot, + block_time: 0, }), route, ))) diff --git a/crates/plugin/src/stats.rs b/crates/plugin/src/stats.rs index 89690c6..78a203e 100644 --- a/crates/plugin/src/stats.rs +++ b/crates/plugin/src/stats.rs @@ -184,7 +184,7 @@ fn send_stats( stats_to_send.push(stats_clone); //clear existing - *slot_stat = SlotStatistics::default(); + slot_stat.clear(); } } let producer = producer.clone(); diff --git a/crates/rabbitmq/src/geyser.rs b/crates/rabbitmq/src/geyser.rs index e098509..4c28481 100644 --- a/crates/rabbitmq/src/geyser.rs +++ b/crates/rabbitmq/src/geyser.rs @@ -37,6 +37,9 @@ pub struct AccountUpdate { pub write_version: u64, /// The slot in which this account was updated pub slot: u64, + /// The block_time in which this account was updated + /// this is not known during processing, but is filled out by confirmooor when slots confirm + pub block_time: i64, /// True if this update was triggered by a validator startup pub is_startup: bool, /// First signature of the transaction caused this account modification @@ -55,6 +58,7 @@ impl Into for AccountUpdate { data: base64::encode(self.data), write_version: self.write_version, slot: self.slot, + block_time: self.block_time, is_startup: self.is_startup, txn_signature: self.txn_signature, } @@ -72,6 +76,7 @@ impl From for AccountUpdate { data: base64::decode(ui.data).unwrap(), write_version: ui.write_version, slot: ui.slot, + block_time: ui.block_time, is_startup: ui.is_startup, txn_signature: ui.txn_signature, } @@ -97,6 +102,9 @@ pub struct UiAccountUpdate { pub write_version: u64, /// The slot in which this account was updated pub slot: u64, + /// The block_time in which this account was updated + /// this is not known during processing, but is filled out by confirmooor when slots confirm + pub block_time: i64, /// True if this update was triggered by a validator startup pub is_startup: bool, /// First signature of the transaction caused this account modification @@ -116,6 +124,9 @@ pub struct InstructionNotify { /// The slot in which the transaction including this instruction was /// reported pub slot: u64, + /// The block_time in which this account was updated + /// this is not known during processing, but is filled out by confirmooor when slots confirm + pub block_time: i64, } #[allow(clippy::from_over_into)] @@ -130,6 +141,7 @@ impl Into for InstructionNotify { .map(std::string::ToString::to_string) .collect(), slot: self.slot, + block_time: self.block_time, } } } @@ -141,6 +153,7 @@ impl From for InstructionNotify { data: base64::decode(ui.data).unwrap(), accounts: ui.accounts.iter().map(|a| a.parse().unwrap()).collect(), slot: ui.slot, + block_time: ui.block_time, } } } @@ -158,6 +171,9 @@ pub struct UiInstructionNotify { /// The slot in which the transaction including this instruction was /// reported pub slot: u64, + /// the time of the block + /// this is not known during processing, but is filled out by confirmooor when slots confirm + pub block_time: i64, } /// Message data for an instruction notification @@ -216,6 +232,9 @@ pub enum SlotStatus { pub struct SlotStatistics { ///the slot these stats are for pub slot: u64, + ///the blocktime of the slot + /// this is not known for processing, but is later used in confirmooor + pub block_time: i64, ///count of successful txs pub tx_success: u64, @@ -261,6 +280,7 @@ impl SlotStatistics { ///clear the stats (set all 0) pub fn clear(&mut self) { self.slot = 0; + self.block_time = 0; self.tx_success = 0; self.tx_success_fees = 0; self.tx_success_fees_priority = 0;