Commit 089d6982 authored by Moul's avatar Moul
Browse files

[enh] #7: Use DuniterPy for params retrieval

parent 5011a530
......@@ -15,7 +15,8 @@ You should have received a copy of the GNU Affero General Public License
along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
from silkaj.network_tools import get_request
from silkaj.network_tools import ClientInstance
from duniterpy.api.bma import blockchain
class BlockchainParams(object):
......@@ -27,4 +28,8 @@ class BlockchainParams(object):
return BlockchainParams.__instance
def __init__(self):
self.params = get_request("blockchain/parameters")
self.params = self.get_params()
async def get_params(self):
client = ClientInstance().client
return await client(blockchain.parameters)
......@@ -54,7 +54,7 @@ async def send_certification(cli_args):
req = req["identities"][0]
for cert in req["certifications"]:
if cert["from"] == issuer_pubkey:
params = BlockchainParams().params
params = await BlockchainParams().params
# Change params["msWindow"] to params["sigReplay"] when deployed
# https://git.duniter.org/nodes/typescript/duniter/merge_requests/1270
# Ğ1: 0<–>2y - 2y + 2m
......
......@@ -47,12 +47,15 @@ class CurrencySymbol(object):
return CurrencySymbol.__instance
def __init__(self):
currency = BlockchainParams().params["currency"]
currency = get_currency()
if currency == "g1":
self.symbol = G1_SYMBOL
elif currency == "g1-test":
self.symbol = GTEST_SYMBOL
async def get_params():
currency = await BlockchainParams().params["currency"]
def message_exit(message):
print(message)
......
......@@ -52,7 +52,7 @@ async def received_sent_certifications(id):
time_first_block = first_block["time"]
id_certs = await get_informations_for_identity(id)
certifications = OrderedDict()
params = BlockchainParams().params
params = await BlockchainParams().params
for certs in id_certs["uids"]:
if certs["uid"].lower() == id.lower():
pubkey = id_certs["pubkey"]
......@@ -92,7 +92,7 @@ async def received_sent_certifications(id):
"✔: Certifications written into the blockchain",
)
)
membership_status(certifications, certs, pubkey, req)
await membership_status(certifications, certs, pubkey, req)
await client.close()
......@@ -103,8 +103,8 @@ def cert_written_in_the_blockchain(written_certs, certifieur):
return certifieur["uids"][0]
def membership_status(certifications, certs, pubkey, req):
params = BlockchainParams().params
async def membership_status(certifications, certs, pubkey, req):
params = await BlockchainParams().params
if len(certifications["received"]) >= params["sigQty"]:
print(
"Membership expiration due to certification expirations: "
......
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