Skip to content

Commit

Permalink
fix: add custom loop for waiting for transaction confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
kespinola committed Oct 12, 2023
1 parent db4a8d4 commit fe8bb0d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions consumer/src/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use hub_core::{
backon::{ExponentialBuilder, Retryable},
bs58, clap,
prelude::*,
thiserror,
thiserror, tokio,
uuid::Uuid,
};
use mpl_bubblegum::state::metaplex_adapter::{
Expand Down Expand Up @@ -209,10 +209,9 @@ impl Solana {
&self,
signature: &Signature,
) -> Result<u32, SolanaAssetIdError> {
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
Expand Down Expand Up @@ -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())
}
}
Expand Down

0 comments on commit fe8bb0d

Please sign in to comment.