Skip to content

Instantly share code, notes, and snippets.

@ThomasMeier
Created April 19, 2019 04:08
Show Gist options
  • Save ThomasMeier/6ec2cc622e02f436a03525f543050de8 to your computer and use it in GitHub Desktop.
Save ThomasMeier/6ec2cc622e02f436a03525f543050de8 to your computer and use it in GitHub Desktop.
Sketching a test for readiness
trusted_node_ips = ["http://17.146.74.122:8088/v2/status", "http://98.444.14.152/v2/status", "http://54.555.14.142/v2/status"]
new_node = "http://67.146.66.122:8088/v2/status"
trusted_responses = []
for trusted_node_ip in trusted_node_ips:
resp = requests.get(trusted_node_ip)
trusted_responses.append(resp.json())
new_node_resp = requests.get(new_node)
new_node_status = new_node_resp.json()
# Find greatest highestsavedblock on each of the trusted nodes
highest_saved_trusted = 0
for trusted_response in trusted_responses
if trusted_response.highestsavedblock > highest_saved_trusted:
highest_saved_trusted = trusted_response.highestsavedblock
# Find greatest leader height on each of the trusted nodes
highest_leader_trusted = 0
for trusted_response in trusted_responses
if trusted_response.leaderheight > highest_leader_trusted:
highest_leader_trusted = trusted_response.leaderheight
# Compare to get trusted bool
# TODO add in a neighborhood of acceptability +/- 1 or 2 blocks
is_new_node_trusted = (new_node_status.leaderheight == highest_leader_trusted) and (new_node_status.highestsavedblock == highest_saved_block)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment