Skip to content

Commit

Permalink
add notify
Browse files Browse the repository at this point in the history
  • Loading branch information
imabdulbasit committed Oct 12, 2023
1 parent 347a771 commit a69cd38
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions consumer/src/solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use mpl_token_metadata::{
state::{Creator, DataV2, EDITION, PREFIX},
};
use solana_client::{
client_error::ClientErrorKind, nonblocking::rpc_client::RpcClient as SolanaRpcClient,
client_error::{ClientError, ClientErrorKind},
nonblocking::rpc_client::RpcClient as SolanaRpcClient,
rpc_request::RpcError,
};
use solana_program::{
Expand Down Expand Up @@ -64,12 +65,16 @@ use crate::{

macro_rules! with_retry {
($expr:expr) => {{
(|| async { $expr.await }).retry(
&ExponentialBuilder::default()
.with_jitter()
.with_min_delay(Duration::from_millis(30))
.with_max_times(15),
)
(|| async { $expr.await })
.retry(
&ExponentialBuilder::default()
.with_jitter()
.with_min_delay(Duration::from_millis(30))
.with_max_times(15),
)
.notify(|err: &ClientError, dur: Duration| {
error!("retrying error {:?} in {:?}", err, dur);
})
}};
}

Expand Down Expand Up @@ -202,9 +207,10 @@ 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

0 comments on commit a69cd38

Please sign in to comment.