electrum

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

commit 62f58c18feeb6a3ea79f88382d6b057e34ce347d
parent cffb89002cb7a66b1cf70a42e2e396595ac35bb9
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun, 26 May 2019 05:29:05 +0200

ChannelDB.on_node_announcement: some speed-up

(e.g. for 100 node anns, was ~5 seconds, now 0.7 sec; so still slow)

Diffstat:
Melectrum/lnrouter.py | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/electrum/lnrouter.py b/electrum/lnrouter.py @@ -447,8 +447,9 @@ class ChannelDB(SqlDB): continue node_id = node_info.node_id # Ignore node if it has no associated channel (DoS protection) + # FIXME this is slow expr = or_(ChannelInfo.node1_id==node_id, ChannelInfo.node2_id==node_id) - if self.DBSession.query(ChannelInfo.short_channel_id).filter(expr).count() == 0: + if len(self.DBSession.query(ChannelInfo.short_channel_id).filter(expr).limit(1).all()) == 0: #self.logger.info('ignoring orphan node_announcement') continue node = self.DBSession.query(NodeInfo).filter_by(node_id=node_id).one_or_none()