Created
April 19, 2019 04:08
-
-
Save ThomasMeier/6ec2cc622e02f436a03525f543050de8 to your computer and use it in GitHub Desktop.
Revisions
-
ThomasMeier created this gist
Apr 19, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ 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)