Browse Source

start lngossip if instantiated; this saves a boolean

patch-4
ThomasV 4 years ago
parent
commit
f155f3aff5
  1. 2
      electrum/gui/qt/main_window.py
  2. 4
      electrum/lnworker.py
  3. 5
      electrum/network.py

2
electrum/gui/qt/main_window.py

@ -2193,7 +2193,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
def update_lightning_icon(self):
if self.lightning_button is None:
return
if not self.network.lngossip.has_started:
if self.network.lngossip is None:
return
# display colorful lightning icon to signal connection

4
electrum/lnworker.py

@ -449,15 +449,11 @@ class LNGossip(LNWorker):
self.features |= LnFeatures.GOSSIP_QUERIES_OPT
self.features |= LnFeatures.GOSSIP_QUERIES_REQ
self.unknown_ids = set()
self.has_started = False
def start_network(self, network: 'Network'):
assert network
if self.has_started:
return
super().start_network(network)
asyncio.run_coroutine_threadsafe(self.taskgroup.spawn(self.maintain_db()), self.network.asyncio_loop)
self.has_started = True
async def maintain_db(self):
await self.channel_db.data_loaded.wait()

5
electrum/network.py

@ -349,14 +349,15 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
def maybe_init_lightning(self):
if self.channel_db is None:
from . import lnworker
from . import lnrouter
from . import channel_db
self.channel_db = channel_db.ChannelDB(self)
self.path_finder = lnrouter.LNPathFinder(self.channel_db)
self.lngossip = lnworker.LNGossip()
def start_gossip(self):
if self.lngossip is None:
from . import lnworker
self.lngossip = lnworker.LNGossip()
self.lngossip.start_network(self)
def stop_gossip(self):

Loading…
Cancel
Save