Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Jul 8, 2024
1 parent 614e182 commit 80861c3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions cashu/mint/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ async def get_mint_quote(self, quote_id: str) -> MintQuote:
unit
].get_invoice_status(quote.checking_id)
if status.paid:
# change state to paid in one transaction
# change state to paid in one transaction, it could have been marked paid
# by the invoice listener in the mean time
async with self.db.get_connection(
lock_table="mint_quotes", lock_select_statement=f"quote={quote_id}"
) as conn:
Expand All @@ -484,16 +485,15 @@ async def get_mint_quote(self, quote_id: str) -> MintQuote:
)
if not quote:
raise Exception("quote not found")
if not quote.state == MintQuoteState.unpaid:
return quote
logger.trace(f"Setting quote {quote_id} as paid")
quote.paid = True
quote.state = MintQuoteState.paid
quote.paid_time = int(time.time())
await self.crud.update_mint_quote(
quote=quote, db=self.db, conn=conn
)
await self.events.submit(quote)
if quote.state == MintQuoteState.unpaid:
logger.trace(f"Setting quote {quote_id} as paid")
quote.paid = True
quote.state = MintQuoteState.paid
quote.paid_time = int(time.time())
await self.crud.update_mint_quote(
quote=quote, db=self.db, conn=conn
)
await self.events.submit(quote)

return quote

Expand Down

0 comments on commit 80861c3

Please sign in to comment.