Optimize follow-invoices service performance (#480)

This commit is contained in:
Reckless_Satoshi 2023-04-30 13:46:23 +00:00 committed by GitHub
parent fcd6e25073
commit c693faacde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -288,8 +288,6 @@ class LNNode:
pass pass
status = lnd_response_state_to_lnpayment_status[response.state] status = lnd_response_state_to_lnpayment_status[response.state]
lnpayment.status = status
lnpayment.save()
except Exception as e: except Exception as e:
# If it fails at finding the invoice: it has been canceled. # If it fails at finding the invoice: it has been canceled.
@ -297,8 +295,6 @@ class LNNode:
if "unable to locate invoice" in str(e): if "unable to locate invoice" in str(e):
print(str(e)) print(str(e))
status = LNPayment.Status.CANCEL status = LNPayment.Status.CANCEL
lnpayment.status = status
lnpayment.save()
# LND restarted. # LND restarted.
if "wallet locked, unlock it" in str(e): if "wallet locked, unlock it" in str(e):

View File

@ -59,16 +59,16 @@ class Command(BaseCommand):
at_least_one_changed = False at_least_one_changed = False
for idx, hold_lnpayment in enumerate(queryset): for idx, hold_lnpayment in enumerate(queryset):
old_status = LNPayment.Status(hold_lnpayment.status).label old_status = hold_lnpayment.status
status = LNNode.lookup_invoice_status(hold_lnpayment) new_status = LNNode.lookup_invoice_status(hold_lnpayment)
new_status = LNPayment.Status(status).label
# Only save the hold_payments that change (otherwise this function does not scale) # Only save the hold_payments that change (otherwise this function does not scale)
changed = not old_status == new_status changed = not old_status == new_status
if changed: if changed:
# self.handle_status_change(hold_lnpayment, old_status) # self.handle_status_change(hold_lnpayment, old_status)
self.update_order_status(hold_lnpayment) self.update_order_status(hold_lnpayment)
hold_lnpayment.status = new_status
hold_lnpayment.save() hold_lnpayment.save()
# Report for debugging # Report for debugging