From 800847444868162c6be2972807336b8f02b02d02 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Fri, 6 Jul 2018 17:00:31 +0200 Subject: [PATCH] [mod] give best_node() boolean values. - Fix boolean values sent to 'info' and 'argos' cmds. --- bin/silkaj | 2 +- silkaj/commands.py | 2 +- silkaj/network_tools.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/silkaj b/bin/silkaj index 8394050d..85c76751 100755 --- a/bin/silkaj +++ b/bin/silkaj @@ -9,5 +9,5 @@ if __name__ == '__main__': ep, cli_args = cli() if not check_port(ep["port"]): exit(1) - best_node(ep, 1) + best_node(ep, True) manage_cmd(ep, cli_args) diff --git a/silkaj/commands.py b/silkaj/commands.py index 9625a75e..b6bd6b43 100644 --- a/silkaj/commands.py +++ b/silkaj/commands.py @@ -110,7 +110,7 @@ def network_info(ep, discover): print("Getting informations about nodes:") while (i < len(endpoints)): print("{0:.0f}%".format(i/len(endpoints) * 100, 1), end=" ") - best_ep = best_node(endpoints[i], 0) + best_ep = best_node(endpoints[i], False) print(best_ep if best_ep is None else endpoints[i][best_ep], end=" ") print(endpoints[i]["port"]) try: diff --git a/silkaj/network_tools.py b/silkaj/network_tools.py index d0482307..ebfba4d4 100644 --- a/silkaj/network_tools.py +++ b/silkaj/network_tools.py @@ -19,7 +19,7 @@ def discover_peers(ep, discover): for i, ep in enumerate(endpoints): if discover: print("{0:.0f}%".format(i / len(endpoints) * 100)) - if best_node(ep, 0) is None: + if best_node(ep, False) is None: endpoints.remove(ep) elif discover: endpoints = recursive_discovering(endpoints, ep) @@ -33,7 +33,7 @@ def recursive_discovering(endpoints, ep): """ news = parse_endpoints(get_request(ep, "network/peers")["peers"]) for new in news: - if best_node(new, 0) is not None and new not in endpoints: + if best_node(new, False) is not None and new not in endpoints: endpoints.append(new) recursive_discovering(endpoints, new) return endpoints @@ -100,7 +100,7 @@ def check_ip(address): def get_request(ep, path): - address = best_node(ep, 0) + address = best_node(ep, False) if address is None: return address url = "http://" + ep[address] + ":" + ep["port"] + "/" + path @@ -113,7 +113,7 @@ def get_request(ep, path): def post_request(ep, path, postdata): - address = best_node(ep, 0) + address = best_node(ep, False) if address is None: return address url = "http://" + ep[address] + ":" + ep["port"] + "/" + path -- GitLab