From f10752b5237de5da9a873fd1c62750a997b95abe Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 26 Apr 2022 19:20:59 +0200 Subject: [PATCH] lnworker: LNWallet.start_network to call super().start_network The call to super was removed in https://github.com/spesmilo/electrum/commit/4efcb53d24d5f1040556d5fb4194eb8007943602 , so that LNWallet's taskgroup would not run _maintain_connectivity, AFAICT. The way it was done meant that "main_loop" itself would not run for LNWallet, only for LNGossip - very confusing. It is only due to a quirk in the behaviour of TaskGroups that the group "started" at all. --- electrum/lnworker.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 568711e00..3c3bff478 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -266,7 +266,7 @@ class LNWorker(Logger, NetworkRetryManager[LNPeerAddr]): self.logger.info("starting taskgroup.") try: async with self.taskgroup as group: - await group.spawn(self._maintain_connectivity()) + await group.spawn(asyncio.Event().wait) # run forever (until cancel) except Exception as e: self.logger.exception("taskgroup died.") finally: @@ -516,9 +516,13 @@ class LNGossip(LNWorker): self.unknown_ids = set() def start_network(self, network: 'Network'): - assert network super().start_network(network) - asyncio.run_coroutine_threadsafe(self.taskgroup.spawn(self.maintain_db()), self.network.asyncio_loop) + for coro in [ + self._maintain_connectivity(), + self.maintain_db(), + ]: + tg_coro = self.taskgroup.spawn(coro) + asyncio.run_coroutine_threadsafe(tg_coro, self.network.asyncio_loop) async def maintain_db(self): await self.channel_db.data_loaded.wait() @@ -727,9 +731,7 @@ class LNWallet(LNWorker): await watchtower.add_sweep_tx(outpoint, ctn, tx.inputs()[0].prevout.to_str(), tx.serialize()) def start_network(self, network: 'Network'): - assert network - self.network = network - self.config = network.config + super().start_network(network) self.lnwatcher = LNWalletWatcher(self, network) self.lnwatcher.start_network(network) self.swap_manager.start_network(network=network, lnwatcher=self.lnwatcher)