From 2cbb63be416f1649c56f1515967f9aa8ffea44a5 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Wed, 12 Dec 2018 11:39:40 +0100 Subject: [PATCH] [enh] BMA: Add blockchain/difficulties schema and method --- duniterpy/api/bma/blockchain.py | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/duniterpy/api/bma/blockchain.py b/duniterpy/api/bma/blockchain.py index a76e587b..87ed3203 100644 --- a/duniterpy/api/bma/blockchain.py +++ b/duniterpy/api/bma/blockchain.py @@ -303,6 +303,38 @@ HARDSHIP_SCHEMA = { "required": ["block", "level"] } +DIFFICULTIES_SCHEMA = { + "type": "object", + "properties": { + "block": { + "type": "number" + }, + "levels": { + "type": "array", + "items": [ + { + "type": "object", + "properties": { + "uid": { + "type": "string" + }, + "level": { + "type": "number" + } + }, + "required": [ + "uid", + "level" + ] + } + ] + } + }, + "required": [ + "block", + "levels" + ] +} async def parameters(client: Client) -> dict: """ @@ -391,6 +423,16 @@ async def hardship(client: Client, pubkey: str) -> dict: return await client.get(MODULE + '/hardship/%s' % pubkey, schema=HARDSHIP_SCHEMA) +async def difficulties(client: Client) -> dict: + """ + GET difficulties levels for members into current window for writing next block + + :param client: Client to connect to the api + :return: + """ + return await client.get(MODULE + '/difficulties', schema=DIFFICULTIES_SCHEMA) + + async def newcomers(client: Client) -> dict: """ GET the block numbers containing newcomers -- GitLab