Skip to content
Snippets Groups Projects
Commit 047a313b authored by matograine's avatar matograine
Browse files

[mod] #344 use pendulum in silkaj.commands

parent 60cc32f2
No related branches found
No related tags found
No related merge requests found
......@@ -15,15 +15,14 @@ You should have received a copy of the GNU Affero General Public License
along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
import aiohttp, pendulum, jsonschema
from click import command, option, argument, IntRange
from os import system
from collections import OrderedDict
from tabulate import tabulate
from operator import itemgetter
from asyncio import sleep
import aiohttp
from _socket import gaierror
import jsonschema
from duniterpy.api import bma
......@@ -36,8 +35,7 @@ from silkaj.network_tools import (
)
from silkaj.blockchain_tools import HeadBlock
from silkaj.tools import CurrencySymbol
from silkaj.tui import convert_time
from silkaj.constants import ASYNC_SLEEP
from silkaj.constants import ASYNC_SLEEP, ALL, DATE, HOUR
@command("info", help="Display information about currency")
......@@ -58,11 +56,13 @@ async def currency_info():
"\nMinimal Proof-of-Work:",
head_block["powMin"],
"\nCurrent time:",
convert_time(head_block["time"], "all"),
pendulum.from_timestamp(head_block["time"]).format(ALL),
"\nMedian time:",
convert_time(head_block["medianTime"], "all"),
pendulum.from_timestamp(head_block["medianTime"]).format(ALL),
"\nDifference time:",
convert_time(head_block["time"] - head_block["medianTime"], "hour"),
pendulum.from_timestamp(head_block["time"] - head_block["medianTime"]).format(
HOUR
),
)
client = ClientInstance().client
await client.close()
......@@ -129,7 +129,7 @@ def display_diffi(current, diffi):
Generation of next block n°{2} possible by at least {3}/{4} members\n\
Common Proof-of-Work difficulty level: {5}, hash starting with `{6}`\n{7}".format(
current["number"],
convert_time(current["time"], "all"),
pendulum.from_timestamp(current["time"]).format(ALL),
diffi["block"],
issuers,
len(diffi["levels"]),
......@@ -165,8 +165,10 @@ async def list_blocks(number, detailed):
issuer["pubkey"] = block["issuer"]
if detailed or number <= 30:
issuer["block"] = block["number"]
issuer["gentime"] = convert_time(block["time"], "all")
issuer["mediantime"] = convert_time(block["medianTime"], "all")
issuer["gentime"] = pendulum.from_timestamp(block["time"]).format(ALL)
issuer["mediantime"] = pendulum.from_timestamp(block["medianTime"]).format(
ALL
)
issuer["hash"] = block["hash"][:10]
issuer["powMin"] = block["powMin"]
issuers_dict[issuer["pubkey"]] = issuer
......@@ -257,11 +259,13 @@ async def argos_info():
"\nMinimal Proof-of-Work:",
head_block["powMin"],
"\nCurrent time:",
convert_time(head_block["time"], "all"),
pendulum.from_timestamp(head_block["time"]).format(ALL),
"\nMedian time:",
convert_time(head_block["medianTime"], "all"),
pendulum.from_timestamp(head_block["medianTime"]).format(ALL),
"\nDifference time:",
convert_time(head_block["time"] - head_block["medianTime"], "hour"),
pendulum.from_timestamp(head_block["time"] - head_block["medianTime"]).format(
HOUR
),
)
client = ClientInstance().client
await client.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment