MCPcopy
hub / github.com/raiden-network/raiden / wait_for_reachable

Function wait_for_reachable

tools/debugging/stress_test_transfers.py:203–229  ·  view source on GitHub ↗

Wait until the nodes used for the transfers can see each other.

(
    transfers: List[TransferPath], token_address: str, retry_timeout: int
)

Source from the content-addressed store, hash-verified

201
202
203def wait_for_reachable(
204 transfers: List[TransferPath], token_address: str, retry_timeout: int
205) -> None:
206 """Wait until the nodes used for the transfers can see each other."""
207
208 # Deduplicate the URLs for the channels which need reachability testing
209 channels_not_reachable = set()
210 for transfer in transfers:
211 for payer, payee in zip(transfer, transfer[1:]):
212 channel_url = f"{payer.url}/api/v1/channels/{token_address}/{payee.config.address}"
213 channels_not_reachable.add(channel_url)
214
215 # Now wait until every reachability constraint is satisfied
216 while channels_not_reachable:
217 log.info(f"Waiting for reachability of partner nodes: {channels_not_reachable}")
218
219 for url in channels_not_reachable.copy():
220 response = requests.get(url, headers={"Content-Type": "application/json"})
221 data = response.json()
222
223 # The return data **may** be `None`, this looks like a race
224 # condition in the Raiden client REST API.
225 if data and data.get("network_state") == NetworkState.REACHABLE.value:
226 channels_not_reachable.remove(url)
227
228 if channels_not_reachable:
229 gevent.sleep(retry_timeout)
230
231
232def start_and_wait_for_server(

Callers 1

run_stress_testFunction · 0.85

Calls 4

copyMethod · 0.80
jsonMethod · 0.80
removeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected