From a69cd387bd25b44878461b27832825e65c2cc3e9 Mon Sep 17 00:00:00 2001 From: imabdulbasit Date: Thu, 12 Oct 2023 13:31:34 +0500 Subject: [PATCH] add notify --- consumer/src/solana.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/consumer/src/solana.rs b/consumer/src/solana.rs index 27fb5b5..0ce1681 100644 --- a/consumer/src/solana.rs +++ b/consumer/src/solana.rs @@ -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::{ @@ -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); + }) }}; } @@ -202,9 +207,10 @@ 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