Browse Source

wallet: delete_{invoice,request}: add "write_to_disk=True" param

to support faster batch-deletion
patch-4
SomberNight 2 years ago
parent
commit
396a68cb58
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 3
      electrum/gui/qt/invoice_list.py
  2. 3
      electrum/gui/qt/request_list.py
  3. 10
      electrum/wallet.py

3
electrum/gui/qt/invoice_list.py

@ -194,5 +194,6 @@ class InvoiceList(MyTreeView):
def delete_invoices(self, keys):
for key in keys:
self.wallet.delete_invoice(key)
self.wallet.delete_invoice(key, write_to_disk=False)
self.delete_item(key)
self.wallet.save_db()

3
electrum/gui/qt/request_list.py

@ -192,6 +192,7 @@ class RequestList(MyTreeView):
def delete_requests(self, keys):
for key in keys:
self.wallet.delete_request(key)
self.wallet.delete_request(key, write_to_disk=False)
self.delete_item(key)
self.wallet.save_db()
self.receive_tab.do_clear()

10
electrum/wallet.py

@ -2517,7 +2517,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
self.save_db()
return key
def delete_request(self, key):
def delete_request(self, key, *, write_to_disk: bool = True):
""" lightning or on-chain """
req = self._receive_requests.pop(key, None)
if req is None:
@ -2526,16 +2526,18 @@ class Abstract_Wallet(ABC, Logger, EventListener):
self._requests_addr_to_rhash.pop(addr)
if req.is_lightning() and self.lnworker:
self.lnworker.delete_payment_info(req.rhash)
self.save_db()
if write_to_disk:
self.save_db()
def delete_invoice(self, key):
def delete_invoice(self, key, *, write_to_disk: bool = True):
""" lightning or on-chain """
inv = self._invoices.pop(key, None)
if inv is None:
return
if inv.is_lightning() and self.lnworker:
self.lnworker.delete_payment_info(inv.rhash)
self.save_db()
if write_to_disk:
self.save_db()
def get_sorted_requests(self) -> List[Invoice]:
""" sorted by timestamp """

Loading…
Cancel
Save