Browse Source

invoices: improve perf by caching lnaddr even earlier

During wallet-open, we load all invoices/payreqs. This involved decoding the lnaddrs twice.
Now we only decode once.

For a wallet with ~1000 payreqs, this noticeably sped up wallet-open:
(before:)
8.83 | D | util.profiler | Daemon._load_wallet 6.4317 sec
(after:)
5.69 | D | util.profiler | Daemon._load_wallet 3.4450 sec

It is very expensive to parse all the lnaddrs...
master
SomberNight 3 years ago
parent
commit
ad0b853cd9
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 1
      electrum/daemon.py
  2. 3
      electrum/invoices.py

1
electrum/daemon.py

@ -463,6 +463,7 @@ class Daemon(Logger):
return wallet return wallet
@staticmethod @staticmethod
@profiler
def _load_wallet( def _load_wallet(
path, path,
password, password,

3
electrum/invoices.py

@ -196,7 +196,8 @@ class Invoice(StoredObject):
@lightning_invoice.validator @lightning_invoice.validator
def _validate_invoice_str(self, attribute, value): def _validate_invoice_str(self, attribute, value):
if value is not None: if value is not None:
lndecode(value) # this checks the str can be decoded lnaddr = lndecode(value) # this checks the str can be decoded
self.__lnaddr = lnaddr # save it, just to avoid having to recompute later
@amount_msat.validator @amount_msat.validator
def _validate_amount(self, attribute, value): def _validate_amount(self, attribute, value):

Loading…
Cancel
Save