mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
ln: fix race in on_network_update
This commit is contained in:
parent
d5cb21143f
commit
2fd5f8613a
1 changed files with 21 additions and 15 deletions
|
@ -114,6 +114,11 @@ class LNWorker(PrintError):
|
||||||
self.network.trigger_callback('channel', chan)
|
self.network.trigger_callback('channel', chan)
|
||||||
|
|
||||||
def on_network_update(self, event, *args):
|
def on_network_update(self, event, *args):
|
||||||
|
""" called from network thread """
|
||||||
|
# Race discovered in save_channel (assertion failing):
|
||||||
|
# since short_channel_id could be changed while saving.
|
||||||
|
# Mitigated by posting to loop:
|
||||||
|
async def network_jobs():
|
||||||
for chan in self.channels.values():
|
for chan in self.channels.values():
|
||||||
if chan.state == "OPENING":
|
if chan.state == "OPENING":
|
||||||
res = self.save_short_chan_id(chan)
|
res = self.save_short_chan_id(chan)
|
||||||
|
@ -129,6 +134,7 @@ class LNWorker(PrintError):
|
||||||
conf = self.wallet.get_tx_height(chan.funding_outpoint.txid)[1]
|
conf = self.wallet.get_tx_height(chan.funding_outpoint.txid)[1]
|
||||||
peer = self.peers[chan.node_id]
|
peer = self.peers[chan.node_id]
|
||||||
peer.on_network_update(chan, conf)
|
peer.on_network_update(chan, conf)
|
||||||
|
asyncio.run_coroutine_threadsafe(network_jobs(), self.network.asyncio_loop).result()
|
||||||
|
|
||||||
async def _open_channel_coroutine(self, node_id, local_amount_sat, push_sat, password):
|
async def _open_channel_coroutine(self, node_id, local_amount_sat, push_sat, password):
|
||||||
peer = self.peers[node_id]
|
peer = self.peers[node_id]
|
||||||
|
|
Loading…
Add table
Reference in a new issue