Browse Source

ChannelDB.on_node_announcement: some speed-up

(e.g. for 100 node anns, was ~5 seconds, now 0.7 sec; so still slow)
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 6 years ago
committed by ThomasV
parent
commit
62f58c18fe
  1. 3
      electrum/lnrouter.py

3
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()

Loading…
Cancel
Save