From fe8bb0da62e4592afea67698fe334815ae540104 Mon Sep 17 00:00:00 2001 From: Kyle Espinola Date: Thu, 12 Oct 2023 13:25:44 +0200 Subject: [PATCH] fix: add custom loop for waiting for transaction confirmation --- consumer/src/solana.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/consumer/src/solana.rs b/consumer/src/solana.rs index 86d1e8e..29ced17 100644 --- a/consumer/src/solana.rs +++ b/consumer/src/solana.rs @@ -12,7 +12,7 @@ use hub_core::{ backon::{ExponentialBuilder, Retryable}, bs58, clap, prelude::*, - thiserror, + thiserror, tokio, uuid::Uuid, }; use mpl_bubblegum::state::metaplex_adapter::{ @@ -209,10 +209,9 @@ impl Solana { &self, signature: &Signature, ) -> Result { - let response = with_retry!( - self.rpc() - .get_transaction(signature, UiTransactionEncoding::Json) - ) + let response = with_retry!(self + .rpc() + .get_transaction(signature, UiTransactionEncoding::Json)) .await?; let meta = response @@ -291,6 +290,16 @@ impl Solana { anyhow!(msg) })?; + loop { + let confirmed = with_retry!(self.rpc().confirm_transaction(&signature)).await?; + + if confirmed { + break; + } + + tokio::time::sleep(std::time::Duration::from_millis(250)).await; + } + Ok(signature.to_string()) } }