Skip to content

Commit

Permalink
get rid of forever loop
Browse files Browse the repository at this point in the history
  • Loading branch information
scx1332 committed Oct 26, 2023
1 parent 62f9026 commit 1e04506
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion agent/provider/src/payments/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ impl Handler<IssueInvoice> for Payments {
async move {
log::debug!("Issuing invoice {}.", serde_json::to_string(&invoice)?);

loop {
let max_retries = 3;
for _ in 0..max_retries {
match provider_ctx.payment_api.issue_invoice(&invoice).await {
Ok(invoice) => {
log::info!("Invoice [{}] issued.", invoice.invoice_id);
Expand All @@ -836,6 +837,7 @@ impl Handler<IssueInvoice> for Payments {
}
}
}
Err(anyhow!("Failed to issue invoice after {} retries.", max_retries))
}
.boxed_local()
}
Expand Down

0 comments on commit 1e04506

Please sign in to comment.