Skip to content

Commit

Permalink
Simplify logic in get_edges_for_peers.
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Aug 21, 2016
1 parent 3c90628 commit 7ec28c3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions scripts/sendGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,17 @@ def get_edges_for_peers(edges, peers, node_ip):
for peer_key in peers:
peer_ip = key_utils.to_ipv6(peer_key)

if node_ip > peer_ip:
A = node_ip
B = peer_ip
else:
A = peer_ip
B = node_ip
A = max(node_ip, peer_ip)
B = min(node_ip, peer_ip)

edge = { 'a': A,
'b': B }

if A not in edges:
edges[A] = []

if not([True for edge in edges[A] if edge['b'] == B]):
edges[A] += [edge]
if not any(edge['b'] == B for edge in edges[A]):
edges[A].append(edge)


def send_graph(nodes, edges):
Expand Down

0 comments on commit 7ec28c3

Please sign in to comment.