5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-11-24 14:31:35 +00:00

Simplify logic in get_edges_for_peers.

This commit is contained in:
Valentin Lorentz 2016-08-21 11:21:27 +02:00
parent 3c90628f74
commit 7ec28c3a0a

View File

@ -215,12 +215,8 @@ def get_edges_for_peers(edges, peers, node_ip):
for peer_key in peers: for peer_key in peers:
peer_ip = key_utils.to_ipv6(peer_key) peer_ip = key_utils.to_ipv6(peer_key)
if node_ip > peer_ip: A = max(node_ip, peer_ip)
A = node_ip B = min(node_ip, peer_ip)
B = peer_ip
else:
A = peer_ip
B = node_ip
edge = { 'a': A, edge = { 'a': A,
'b': B } 'b': B }
@ -228,8 +224,8 @@ def get_edges_for_peers(edges, peers, node_ip):
if A not in edges: if A not in edges:
edges[A] = [] edges[A] = []
if not([True for edge in edges[A] if edge['b'] == B]): if not any(edge['b'] == B for edge in edges[A]):
edges[A] += [edge] edges[A].append(edge)
def send_graph(nodes, edges): def send_graph(nodes, edges):