5
0
mirror of https://github.com/cwinfo/yggdrasil-map synced 2024-12-29 02:55:40 +00:00

Merge pull request #17 from ProgVal/simplify-get_edges_for_peers

Simplify logic in get_edges_for_peers.
This commit is contained in:
Michał Zieliński 2016-08-23 22:45:58 +02:00 committed by GitHub
commit 22abb1e2a8

View File

@ -215,12 +215,8 @@ 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 }
@ -228,8 +224,8 @@ def get_edges_for_peers(edges, peers, node_ip):
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):