Commit 17ece06c authored by Moul's avatar Moul
Browse files

[enh] #7: blocks: Use DuniterPy

parent 2e0e29a6
......@@ -167,7 +167,7 @@ async def manage_cmd():
and cli_args.subsubcmd
and int(cli_args.subsubcmd) >= 0
):
list_blocks(int(cli_args.subsubcmd), cli_args.contains_switches("last"))
await list_blocks(int(cli_args.subsubcmd), cli_args.contains_switches("last"))
elif cli_args.subcmd == "argos":
argos_info()
......
......@@ -243,13 +243,14 @@ def network_info(discover):
print(tabulate(endpoints, headers="keys", tablefmt="orgtbl", stralign="center"))
def list_blocks(nbr, last):
async def list_blocks(nbr, last):
head_block = HeadBlock().head_block
current_nbr = head_block["number"]
if nbr == 0:
nbr = head_block["issuersFrame"]
url = "blockchain/blocks/" + str(nbr) + "/" + str(current_nbr - nbr + 1)
blocks, list_issuers, j = get_request(url), list(), 0
client = ClientInstance().client
blocks = await client(blockchain.blocks, nbr, current_nbr - nbr + 1)
list_issuers, j = list(), 0
issuers_dict = dict()
while j < len(blocks):
issuer = OrderedDict()
......@@ -273,6 +274,7 @@ def list_blocks(nbr, last):
):
issuer2["uid"] = uid
issuer2.pop("pubkey")
await client.close()
print(
"Last {0} blocks from n°{1} to n°{2}".format(
nbr, current_nbr - nbr + 1, current_nbr
......
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