From 1cccdb179a32febcfd2d8809a2ee9818318b6520 Mon Sep 17 00:00:00 2001 From: cryptosharks131 Date: Fri, 1 May 2026 19:47:53 -0400 Subject: [PATCH] disable invoice reindex --- jobs.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/jobs.py b/jobs.py index 1cc80cb..92cec50 100644 --- a/jobs.py +++ b/jobs.py @@ -162,29 +162,29 @@ def update_payment(stub, payment, self_pubkey): def update_invoices(stub): # Detect if index out of sync and resync if required - last_invoice_index = stub.ListInvoices(ln.ListInvoiceRequest(reversed=True, num_max_invoices=1)).invoices[0].add_index - last_db_inv_index = Invoices.objects.exclude(state=0).aggregate(Max('index'))['index__max'] or 0 - if last_invoice_index is not None and last_db_inv_index > last_invoice_index: - logger.warning(f'Invoice data index greater than LND index, invoice reindexing triggered') - Invoices.objects.all().update(index=0) - page_size = 300 - index_offset = 0 - while True: - resp = stub.ListInvoices(ln.ListInvoiceRequest( - index_offset=index_offset, - num_max_invoices=page_size - )) - invoices = resp.invoices - for i in invoices: - try: - db_invoice = Invoices.objects.get(r_hash=i.r_hash.hex()) - db_invoice.index = i.add_index - db_invoice.save() - except Invoices.DoesNotExist: - logger.warning(f'Invoice not found during reindex: {i.r_hash.hex()}') - index_offset = resp.last_index_offset - if len(invoices) < page_size: - break + # last_invoice_index = stub.ListInvoices(ln.ListInvoiceRequest(reversed=True, num_max_invoices=1)).invoices[0].add_index + # last_db_inv_index = Invoices.objects.exclude(state=0).aggregate(Max('index'))['index__max'] or 0 + # if last_invoice_index is not None and last_db_inv_index > last_invoice_index: + # logger.warning(f'Invoice data index greater than LND index, invoice reindexing triggered') + # Invoices.objects.all().update(index=0) + # page_size = 300 + # index_offset = 0 + # while True: + # resp = stub.ListInvoices(ln.ListInvoiceRequest( + # index_offset=index_offset, + # num_max_invoices=page_size + # )) + # invoices = resp.invoices + # for i in invoices: + # try: + # db_invoice = Invoices.objects.get(r_hash=i.r_hash.hex()) + # db_invoice.index = i.add_index + # db_invoice.save() + # except Invoices.DoesNotExist: + # logger.warning(f'Invoice not found during reindex: {i.r_hash.hex()}') + # index_offset = resp.last_index_offset + # if len(invoices) < page_size: + # break # Refresh all currently open invoices open_invoices = Invoices.objects.filter(state=0).order_by('index')