diff --git a/silkaj/commands.py b/silkaj/commands.py index 6daed61f7c17cdc3cbc12e895d1291fd43212101..7c5138be79493e18815184f3e15fa591c49228e3 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 74e48fde5ac35a665d7371d2f3caf61090209bb4..ec1a5f22f03b3762be6f135076d91055786baa47 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 4042e6a843535d7c6aac04dd02e5729dc325a938..21134d5835ba13afa230ad05c930af503890b26e 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 6270f71a130024ec6f9a568e9ce7cb457e08d19c..020a44db4772894423f882afd72b989c7c3d988a 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)