Commit 3b6fcbe0 authored by Moul's avatar Moul

[mod] #113 variable/f() renamming

- 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
parent 924a6549
......@@ -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,
......
......@@ -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()
......
......@@ -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"])
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment