Skip to content

Commit

Permalink
try except callback dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Jun 30, 2024
1 parent eb31053 commit daa73f7
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions cashu/mint/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ async def invoice_callback_dispatcher(self, checking_id: str) -> None:
logger.debug(f"Invoice callback dispatcher: {checking_id}")
# TODO: Explicitly check for the quote payment state before setting it as paid
# db read, quote.paid = True, db write should be refactored and moved to ledger.py
quote = await self.crud.get_mint_quote(checking_id=checking_id, db=self.db)
if not quote:
logger.error(f"Quote not found for {checking_id}")
return
# set the quote as paid
if not quote.paid:
quote.paid = True
quote.state = MintQuoteState.paid
await self.crud.update_mint_quote(quote=quote, db=self.db)
logger.trace(f"Quote {quote} set as paid and ")
await self.events.submit(quote)
try:
quote = await self.crud.get_mint_quote(checking_id=checking_id, db=self.db)
if not quote:
logger.error(f"Quote not found for {checking_id}")
return
# set the quote as paid
if not quote.paid:
quote.paid = True
quote.state = MintQuoteState.paid
await self.crud.update_mint_quote(quote=quote, db=self.db)
logger.trace(f"Quote {quote} set as paid and ")
await self.events.submit(quote)
except Exception as e:
logger.error(f"Error in invoice callback dispatcher: {e}")
pass

0 comments on commit daa73f7

Please sign in to comment.