From 3b6fcbe0e0dfb54a83448f26cb51c04cab795bce Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Mon, 25 Mar 2019 22:22:26 +0100
Subject: [PATCH] [mod] #113 variable/f() renamming
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 2) Rename `best_node()` to `best_endpoint_address()`
- 3) argos: print https link in case of port 443
- 4) Use CurrencySymbol singleton
- 6) Remove useless comment
- 11) Term clarification: chart −> table
---
 silkaj/commands.py      | 20 ++++++++++----------
 silkaj/money.py         |  2 --
 silkaj/network_tools.py |  6 +++---
 silkaj/wot.py           |  2 +-
 4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/silkaj/commands.py b/silkaj/commands.py
index 6daed61f..7c5138be 100644
--- a/silkaj/commands.py
+++ b/silkaj/commands.py
@@ -33,7 +33,7 @@ from silkaj.tools import coroutine
 from silkaj.wot import get_uid_from_pubkey
 from silkaj.network_tools import (
     discover_peers,
-    best_node,
+    best_endpoint_address,
     EndPoint,
     ClientInstance,
     HeadBlock,
@@ -49,7 +49,7 @@ async def currency_info():
     ep = EndPoint().ep
     print(
         "Connected to node:",
-        ep[best_node(ep, False)],
+        ep[best_endpoint_address(ep, False)],
         ep["port"],
         "\nCurrent block number:",
         head_block["number"],
@@ -198,7 +198,7 @@ async def network_info(discover, sort):
         api += ep.get("ip6") + " " if ep["ip6"] else ""
         api += ep.get("port")
         print("{0:.0f}%".format(i / len(infos) * 100, 1), end=" ")
-        best_ep = best_node(info, False)
+        best_ep = best_endpoint_address(info, False)
         print(best_ep if best_ep is None else info[best_ep], end=" ")
         print(info["port"])
         try:
@@ -351,18 +351,18 @@ async def list_blocks(number, detailed):
 @command("argos", help="Display currency information formated for Argos or BitBar")
 @coroutine
 async def argos_info():
-    pretty_names = {"g1": "Äž1", "gtest": "Äžtest"}
     head_block = await HeadBlock().head_block
-    pretty = head_block["currency"]
-    if head_block["currency"] in pretty_names:
-        pretty = pretty_names[head_block["currency"]]
-    print(pretty, "|")
+    print(await CurrencySymbol().symbol, "|")
     print("---")
     ep = EndPoint().ep
-    href = "href=http://%s:%s/" % (ep[best_node(ep, False)], ep["port"])
+    endpoint_address = ep[best_endpoint_address(ep, False)]
+    if ep["port"] == "443":
+        href = "href=https://%s/" % (endpoint_address)
+    else:
+        href = "href=http://%s:%s/" % (endpoint_address, ep["port"])
     print(
         "Connected to node:",
-        ep[best_node(ep, False)],
+        ep[best_endpoint_address(ep, False)],
         ep["port"],
         "|",
         href,
diff --git a/silkaj/money.py b/silkaj/money.py
index 74e48fde..ec1a5f22 100644
--- a/silkaj/money.py
+++ b/silkaj/money.py
@@ -61,8 +61,6 @@ async def cmd_amount(ctx, pubkeys):
 async def show_amount_from_pubkey(pubkey, value):
     totalAmountInput = value[0]
     amount = value[1]
-    # output
-
     currency_symbol = await CurrencySymbol().symbol
     ud_value = await UDValue().ud_value
     average, monetary_mass = await get_average()
diff --git a/silkaj/network_tools.py b/silkaj/network_tools.py
index 4042e6a8..21134d58 100644
--- a/silkaj/network_tools.py
+++ b/silkaj/network_tools.py
@@ -45,7 +45,7 @@ async def discover_peers(discover):
     for i, endpoint in enumerate(endpoints):
         if discover:
             print("{0:.0f}%".format(i / len(endpoints) * 100))
-        if best_node(endpoint, False) is None:
+        if best_endpoint_address(endpoint, False) is None:
             endpoints.remove(endpoint)
         elif discover:
             endpoints = await recursive_discovering(endpoints, endpoint)
@@ -62,7 +62,7 @@ async def recursive_discovering(endpoints, endpoint):
     news = await get_peers_among_leaves(sub_client)
     await sub_client.close()
     for new in news:
-        if best_node(new, False) is not None and new not in endpoints:
+        if best_endpoint_address(new, False) is not None and new not in endpoints:
             endpoints.append(new)
             await recursive_discovering(endpoints, new)
     return endpoints
@@ -193,7 +193,7 @@ def check_ip(address):
         return 0
 
 
-def best_node(ep, main):
+def best_endpoint_address(ep, main):
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     s.settimeout(CONNECTION_TIMEOUT)
     addresses, port = ("domain", "ip6", "ip4"), int(ep["port"])
diff --git a/silkaj/wot.py b/silkaj/wot.py
index 6270f71a..020a44db 100644
--- a/silkaj/wot.py
+++ b/silkaj/wot.py
@@ -52,7 +52,7 @@ async def received_sent_certifications(id):
     """
     get searched id
     get id of received and sent certifications
-    display on a chart the result with the numbers
+    display in a table the result with the numbers
     """
     client = ClientInstance().client
     first_block = await client(blockchain.block, 1)
-- 
GitLab