Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix waiting for light clients
Browse files Browse the repository at this point in the history
reliveyy committed Nov 2, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
reliveyy bitdancer
1 parent f7c9256 commit 911a4a8
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions images/utils/launcher/check_wallets.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import os
import docker
import time
from concurrent.futures import ThreadPoolExecutor
from concurrent.futures import ThreadPoolExecutor, wait
from docker.models.containers import Container
from datetime import datetime
import re
@@ -276,7 +276,10 @@ def ensure_layer2_ready(self) -> None:
nodes = self.config.nodes
if self.node_manager.newly_installed:
if self.network == "simnet":
self.lnd_cfheaders["bitcoin"] = CFHeaderState()
if self.config.nodes["lndbtc"]["mode"] == "native":
self.lnd_cfheaders["bitcoin"] = CFHeaderState()
if self.config.nodes["lndltc"]["mode"] == "native":
self.lnd_cfheaders["litecoin"] = CFHeaderState()
self.lnd_cfheaders["litecoin"] = CFHeaderState()
if "bitcoind" in nodes and nodes["bitcoind"]["mode"] in ["neutrino", "light"]:
self.lnd_cfheaders["bitcoin"] = CFHeaderState()
@@ -287,27 +290,18 @@ def ensure_layer2_ready(self) -> None:
print("Syncing light clients:")
self._print_lnd_cfheaders(erase_last_line=False)

with ThreadPoolExecutor(max_workers=2, thread_name_prefix="LndReady") as executor:
native_lndbtc = self.config.nodes["lndbtc"]["mode"] == "native"
native_lndltc = self.config.nodes["lndltc"]["mode"] == "native"

if native_lndbtc:
f1 = executor.submit(self.ensure_lnd_ready, "bitcoin")
with ThreadPoolExecutor(max_workers=len(self.lnd_cfheaders), thread_name_prefix="LndReady") as executor:
futs = {}
for chain in self.lnd_cfheaders:
futs[executor.submit(self.ensure_lnd_ready, chain)] = chain

if native_lndltc:
f2 = executor.submit(self.ensure_lnd_ready, "litecoin")
done, not_done = wait(futs)

if native_lndbtc:
try:
f1.result()
except Exception as e:
raise FatalError("Failed to wait for lndbtc to be ready") from e

if native_lndltc:
try:
f2.result()
except Exception as e:
raise FatalError("Failed to wait for lndltc to be ready") from e
if len(not_done) > 0:
for f in not_done:
f.cancel()
lnds = ", ".join([futs[f] for f in not_done])
raise FatalError("Failed to wait for {} to be ready".format(lnds))

if self.node_manager.newly_installed:
print()

0 comments on commit 911a4a8

Please sign in to comment.