1
0

Fix graceful shutdown for lightning swaps

This commit is contained in:
MrNaif2018
2024-01-09 20:25:09 +03:00
committed by ThomasV
parent 178a03129f
commit 7369145a49
3 changed files with 6 additions and 0 deletions

View File

@@ -967,6 +967,8 @@ class LNWallet(LNWorker):
if self.lnwatcher:
await self.lnwatcher.stop()
self.lnwatcher = None
if self.swap_manager: # may not be present in tests
await self.swap_manager.stop()
async def wait_for_received_pending_htlcs_to_get_removed(self):
assert self.stopping_soon is True

View File

@@ -219,6 +219,9 @@ class SwapManager(Logger):
finally:
self.logger.info("taskgroup stopped.")
async def stop(self):
await self.taskgroup.cancel_remaining()
async def pay_invoice(self, key):
self.logger.info(f'trying to pay invoice {key}')
self.invoices_to_pay[key] = 1000000000000 # lock

View File

@@ -147,6 +147,7 @@ class MockLNWallet(Logger, EventListener, NetworkRetryManager[LNPeerAddr]):
self.network = MockNetwork(tx_queue, config=self.config)
self.taskgroup = OldTaskGroup()
self.lnwatcher = None
self.swap_manager = None
self.listen_server = None
self._channels = {chan.channel_id: chan for chan in chans}
self.payment_info = {}