diff --git a/crates/erc20_payment_lib/src/sender/batching.rs b/crates/erc20_payment_lib/src/sender/batching.rs index e95f7a8f..dfede812 100644 --- a/crates/erc20_payment_lib/src/sender/batching.rs +++ b/crates/erc20_payment_lib/src/sender/batching.rs @@ -52,6 +52,7 @@ pub async fn gather_transactions_pre( account: &SignerAccount, conn: &SqlitePool, payment_setup: &PaymentSetup, + process_tx_needed: &mut bool, ) -> Result { let mut transfer_map = TokenTransferMap::new(); @@ -130,6 +131,7 @@ pub async fn gather_transactions_pre( .map_err(err_from!())?; transaction.commit().await.map_err(err_from!())?; + *process_tx_needed = true; continue; } } diff --git a/crates/erc20_payment_lib/src/sender/service.rs b/crates/erc20_payment_lib/src/sender/service.rs index 6f1e62de..41782677 100644 --- a/crates/erc20_payment_lib/src/sender/service.rs +++ b/crates/erc20_payment_lib/src/sender/service.rs @@ -578,22 +578,28 @@ pub async fn service_loop( log::debug!("Gathering payments..."); - let mut token_transfer_map = - match gather_transactions_pre(&signer_account, conn, payment_setup).await { - Ok(token_transfer_map) => token_transfer_map, - Err(e) => { - metrics::counter!(metric_label_gather_pre_error, 1); - log::error!( + let mut token_transfer_map = match gather_transactions_pre( + &signer_account, + conn, + payment_setup, + &mut process_tx_needed, + ) + .await + { + Ok(token_transfer_map) => token_transfer_map, + Err(e) => { + metrics::counter!(metric_label_gather_pre_error, 1); + log::error!( "Error in gather transactions, driver will be stuck, Fix DB to continue {:?}", e ); - tokio::time::sleep(std::time::Duration::from_secs( - payment_setup.process_interval_after_error, - )) - .await; - continue; - } - }; + tokio::time::sleep(std::time::Duration::from_secs( + payment_setup.process_interval_after_error, + )) + .await; + continue; + } + }; metrics::counter!(metric_label_gather_post, 1); match gather_transactions_post(