Skip to content

Commit

Permalink
Add all the node information available from survey results
Browse files Browse the repository at this point in the history
Currently, the only information we have about each node from surveys is version, numTotalInboundPeers, and numTotalOutboundPeers
  • Loading branch information
Hidenori committed Jun 17, 2020
1 parent 35bf3be commit 09a9449
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions scripts/OverlaySurvey.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
import time


def add_new_node(graph, label, version=""):
if graph.has_node(label) and version == "":
return
graph.add_node(label, label=label, version=version)


def next_peer(direction_tag, node_info):
if direction_tag in node_info and node_info[direction_tag]:
for peer in node_info[direction_tag]:
Expand All @@ -40,12 +34,14 @@ def get_next_peers(topology):

def update_results(graph, parent_info, parent_key, results, is_inbound):
direction_tag = "inboundPeers" if is_inbound else "outboundPeers"
graph.add_node(parent_key,
numTotalInboundPeers=parent_info["numTotalInboundPeers"],
numTotalOutboundPeers=parent_info["numTotalOutboundPeers"])
for peer in next_peer(direction_tag, parent_info):
other_key = peer["nodeId"]

results[direction_tag][other_key] = peer
add_new_node(graph, parent_key)
add_new_node(graph, other_key, peer["version"])
graph.add_node(other_key, version=peer["version"])
edge_properties = peer.copy()
edge_properties.pop("nodeId", None)
edge_properties.pop("version", None)
Expand Down Expand Up @@ -134,13 +130,6 @@ def run_survey(args):
duration = int(args.duration)
params = {'duration': duration}

add_new_node(graph,
requests
.get(url + "/scp?limit=0&fullkeys=true")
.json()
["you"],
requests.get(url + "/info").json()["info"]["build"])

# reset survey
requests.get(url=stop_survey)

Expand All @@ -164,6 +153,14 @@ def run_survey(args):
for peer in peers["outbound"]:
peer_list.append(peer["id"])

graph.add_node(requests
.get(url + "/scp?limit=0&fullkeys=true")
.json()
["you"],
version=requests.get(url + "/info").json()["info"]["build"],
numTotalInboundPeers=len(peers["inbound"] or []),
numTotalOutboundPeers=len(peers["outbound"] or []))

sent_requests = set()

while True:
Expand Down

0 comments on commit 09a9449

Please sign in to comment.