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. 6
      electrum/wallet.py

3
electrum/gui/qt/invoice_list.py

@ -194,5 +194,6 @@ class InvoiceList(MyTreeView):
def delete_invoices(self, keys): def delete_invoices(self, keys):
for key in keys: for key in keys:
self.wallet.delete_invoice(key) self.wallet.delete_invoice(key, write_to_disk=False)
self.delete_item(key) 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): def delete_requests(self, keys):
for key in keys: for key in keys:
self.wallet.delete_request(key) self.wallet.delete_request(key, write_to_disk=False)
self.delete_item(key) self.delete_item(key)
self.wallet.save_db()
self.receive_tab.do_clear() self.receive_tab.do_clear()

6
electrum/wallet.py

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

Loading…
Cancel
Save