From 73973ba0f5022ef9c5b25454432b9b3e331d5e3e Mon Sep 17 00:00:00 2001 From: galactus <96341601+godmodegalactus@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:09:22 +0100 Subject: [PATCH] Check blockhash is expired or not (#351) --- core/src/stores/data_cache.rs | 7 +++++-- services/src/tpu_utils/tpu_connection_manager.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/stores/data_cache.rs b/core/src/stores/data_cache.rs index 6ea29e88..fbb218ee 100644 --- a/core/src/stores/data_cache.rs +++ b/core/src/stores/data_cache.rs @@ -56,11 +56,14 @@ impl DataCache { pub async fn check_if_confirmed_or_expired_blockheight( &self, sent_transaction_info: &SentTransactionInfo, - current_blockheight: u64, ) -> bool { + let last_block = self + .block_information_store + .get_latest_block_info(CommitmentConfig::processed()) + .await; self.txs .is_transaction_confirmed(&sent_transaction_info.signature) - || current_blockheight > sent_transaction_info.last_valid_block_height + || last_block.block_height > sent_transaction_info.last_valid_block_height } pub async fn get_current_epoch(&self, commitment: CommitmentConfig) -> Epoch { diff --git a/services/src/tpu_utils/tpu_connection_manager.rs b/services/src/tpu_utils/tpu_connection_manager.rs index 90e2f39f..f313c46c 100644 --- a/services/src/tpu_utils/tpu_connection_manager.rs +++ b/services/src/tpu_utils/tpu_connection_manager.rs @@ -111,7 +111,7 @@ impl ActiveConnection { let tx: Vec = match tx { Ok(transaction_sent_info) => { - if self.data_cache.txs.is_transaction_confirmed(&transaction_sent_info.signature) { + if self.data_cache.check_if_confirmed_or_expired_blockheight(&transaction_sent_info).await { // transaction is already confirmed/ no need to send continue; }