1
0

lnworker.pay: run path finding in sep. thread (don't block evt loop)

This commit is contained in:
ThomasV
2020-03-10 17:56:11 +01:00
parent df5acd1ea5
commit b6cb983733
2 changed files with 3 additions and 7 deletions

View File

@@ -927,12 +927,11 @@ class LNWallet(LNWorker):
reason = ''
for i in range(attempts):
try:
# note: this call does path-finding which takes ~1 second
# -> we will BLOCK the asyncio loop... (could just run in a thread and await,
# but then the graph could change while the path-finding runs on it)
# note: path-finding runs in a separate thread so that we don't block the asyncio loop
# graph updates might occur during the computation
self.set_invoice_status(key, PR_ROUTING)
self.network.trigger_callback('invoice_status', key)
route = self._create_route_from_invoice(decoded_invoice=lnaddr)
route = await run_in_thread(self._create_route_from_invoice, lnaddr)
self.set_invoice_status(key, PR_INFLIGHT)
self.network.trigger_callback('invoice_status', key)
payment_attempt_log = await self._pay_to_route(route, lnaddr)