Browse Source
wallet: delete_{invoice,request}: add "write_to_disk=True" param
to support faster batch-deletion
patch-4
SomberNight
2 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
3 changed files with
10 additions and
6 deletions
-
electrum/gui/qt/invoice_list.py
-
electrum/gui/qt/request_list.py
-
electrum/wallet.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() |
|
|
|
|
|
@ -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() |
|
|
|
|
|
@ -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,15 +2526,17 @@ 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) |
|
|
|
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) |
|
|
|
if write_to_disk: |
|
|
|
self.save_db() |
|
|
|
|
|
|
|
def get_sorted_requests(self) -> List[Invoice]: |
|
|
|