Skip to content

Commit

Permalink
process needed
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Mar 14, 2024
1 parent 966ea1c commit 2030c88
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions crates/erc20_payment_lib/src/sender/batching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub async fn gather_transactions_pre(
account: &SignerAccount,
conn: &SqlitePool,
payment_setup: &PaymentSetup,
process_tx_needed: &mut bool,
) -> Result<TokenTransferMap, PaymentError> {
let mut transfer_map = TokenTransferMap::new();

Expand Down Expand Up @@ -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;
}
}
Expand Down
32 changes: 19 additions & 13 deletions crates/erc20_payment_lib/src/sender/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2030c88

Please sign in to comment.