Skip to content

Commit 1af374d

Browse files
committed
qt: don't refresh invoice list per invoice_status event while syncing
Each invoice_status event makes InvoiceList.refresh_item recompute the invoice status, which scans prevouts, on the GUI thread. While the wallet is syncing these events arrive in bulk - one per touched invoice per tx addition - so a wallet with many invoices sharing a destination scriptpubkey freezes the GUI for the duration of the sync (observed via py-spy: the GUI thread inside _is_onchain_invoice_paid under refresh_item, while the event loop thread ran a detection pass). While not up_to_date, just set need_update: update_wallet() already defers update_tabs() until is_up_to_date(), and then rebuilds the invoice list once, in one batch.
1 parent 2f3a181 commit 1af374d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

electrum/gui/qt/main_window.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,12 @@ def on_event_request_status(self, wallet, key, status):
13871387
def on_event_invoice_status(self, wallet, key, status):
13881388
if wallet != self.wallet:
13891389
return
1390+
if not wallet.is_up_to_date():
1391+
# while syncing, these events arrive in bulk (per touched invoice per tx), and
1392+
# refresh_item recomputes the status, scanning prevouts on the GUI thread.
1393+
# update_wallet() rebuilds the list in one batch once we are up_to_date again.
1394+
self.need_update.set()
1395+
return
13901396
if status == PR_PAID:
13911397
self.send_tab.invoice_list.delete_item(key)
13921398
else:

0 commit comments

Comments
 (0)