From f155f3aff5615cb075e7ce8c8f9beba009b1aacd Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 22 Oct 2020 18:17:13 +0200 Subject: [PATCH] start lngossip if instantiated; this saves a boolean --- electrum/gui/qt/main_window.py | 2 +- electrum/lnworker.py | 4 ---- electrum/network.py | 7 ++++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index e58def2f9..ec338fa66 100644 --- a/electrum/gui/qt/main_window.py +++ b/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 diff --git a/electrum/lnworker.py b/electrum/lnworker.py index db9897a27..dd3fb3224 100644 --- a/electrum/lnworker.py +++ b/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() diff --git a/electrum/network.py b/electrum/network.py index 927a3806d..1ab43110d 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -349,15 +349,16 @@ 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): - self.lngossip.start_network(self) + if self.lngossip is None: + from . import lnworker + self.lngossip = lnworker.LNGossip() + self.lngossip.start_network(self) def stop_gossip(self): self.lngossip.stop()