Skip to content

Commit

Permalink
wait on stellar-core to signal survey end
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Apr 6, 2020
1 parent 3b9e2f1 commit 321866f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions scripts/OverlaySurvey.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ def send_requests(peer_list, params, requestUrl):
requests.get(url=requestUrl, params=params)


def check_results(graph, merged_results, resultUrl):
r = requests.get(url=resultUrl)
data = r.json()

def check_results(data, graph, merged_results):
if "topology" not in data:
raise ValueError("stellar-core is missing survey nodes. Are the public keys surveyed valid?")

Expand Down Expand Up @@ -150,18 +147,24 @@ def run_survey(args):

sent_requests = set()

t_end = time.time() + duration
while time.time() < t_end:
while True:
send_requests(peer_list, PARAMS, SURVEY_REQUEST)

for peer in peer_list:
sent_requests.add(peer)

peer_list = []

# allow time for results
time.sleep(1)
result_node_list = check_results(G, merged_results, SURVEY_RESULT)

r = requests.get(url=SURVEY_RESULT)
data = r.json()

result_node_list = check_results(data, G, merged_results)

if "surveyInProgress" in data and data["surveyInProgress"] == False:
break

# try new nodes
for key in result_node_list:
Expand Down

0 comments on commit 321866f

Please sign in to comment.