electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 99f736f3e73c5b3ed5832f360fefd82e6b289e89
parent 4d6b0184b9a82582a6f56d379eb250d38947785a
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue,  3 Mar 2020 04:04:30 +0100

ChannelDB.load_data: add comment re bad performance, and some speed-up

On my machine, ChannelDB.load_data() went from around 6 sec to 4 sec,
just by commenting out that assert in lnmsg.

related #6006

Diffstat:
Melectrum/channel_db.py | 3+++
Melectrum/lnmsg.py | 3+--
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/electrum/channel_db.py b/electrum/channel_db.py @@ -581,6 +581,9 @@ class ChannelDB(SqlDB): @sql @profiler def load_data(self): + # Note: this method takes several seconds... mostly due to lnmsg.decode_msg being slow. + # I believe lnmsg (and lightning.json) will need a rewrite anyway, so instead of tweaking + # load_data() here, that should be done. see #6006 c = self.conn.cursor() c.execute("""SELECT * FROM address""") for x in c: diff --git a/electrum/lnmsg.py b/electrum/lnmsg.py @@ -57,14 +57,13 @@ def _make_handler(msg_name: str, v: dict) -> Callable[[bytes], Tuple[str, dict]] Returns function taking bytes """ def handler(data: bytes) -> Tuple[str, dict]: - nonlocal msg_name, v ma = {} # map of field name -> field data; after parsing msg pos = 0 for fieldname in v["payload"]: poslenMap = v["payload"][fieldname] if "feature" in poslenMap and pos == len(data): continue - assert pos == _eval_exp_with_ctx(poslenMap["position"], ma) + #assert pos == _eval_exp_with_ctx(poslenMap["position"], ma) # this assert is expensive... length = poslenMap["length"] length = _eval_exp_with_ctx(length, ma) ma[fieldname] = data[pos:pos+length]