Skip to content
Snippets Groups Projects
Commit d8717c28 authored by poka's avatar poka
Browse files

add optionnal future timestamp start

parent 39c80e46
No related branches found
No related tags found
No related merge requests found
from symbol import parameters
from urllib.request import urlopen
from lib.utility import *
from time import time
def get_wallets_data():
......@@ -28,7 +29,7 @@ def get_wallets_data():
return wallets
def get_identities_bloc():
def get_identities_and_wallets(start_timestamp):
# Get wallets data
wallets = get_wallets_data()
......@@ -74,7 +75,8 @@ def get_identities_bloc():
if r_username == None: continue
cert_expire_on_bloc = dateToBlocNumber(blocs[str(cert['writtenOn'])])
if start_timestamp == '': start_timestamp = int(time())
cert_expire_on_bloc = dateToBlocNumber(blocs[str(cert['writtenOn'])], start_timestamp)
if r_username not in identities: identities.update({r_username: {}})
if 'certs' not in identities[r_username]: identities[r_username].update({'certs': []})
......
import json, math
from time import time
import base58
from currency_parameters import CERT_VALIDITY_PERIOD
from substrateinterface import Keypair, KeypairType
currentTimestamp = int(time())
def v1_pubkey_to_v2_address(pubkey):
pubkey_bytes = base58.b58decode(pubkey)
......@@ -20,8 +18,8 @@ def v1_pubkey_to_v2_address(pubkey):
# return V2 address
return keypair.ss58_address
def dateToBlocNumber(timestamp):
cert_duration = currentTimestamp - timestamp
def dateToBlocNumber(timestamp, start_timestamp):
cert_duration = int(start_timestamp) - timestamp
cert_duration_bloc_number = math.trunc(cert_duration / 600)
cert_expire_on_bloc = CERT_VALIDITY_PERIOD - cert_duration_bloc_number
return cert_expire_on_bloc
......
#!/usr/bin/env python3
import base58
import sys
from lib.functions import *
from currency_parameters import *
from lib.get_parameters import *
from lib.get_smiths_and_techs import *
# Get optional arguments
# opt1 = ''
# if len(sys.argv) > 1: opt1=sys.argv[1]
opt1 = ''
if len(sys.argv) > 1: opt1=sys.argv[1]
# Final ĞTest genesis JSON
gtest_genesis = {}
......@@ -32,7 +32,7 @@ gtest_genesis.update({'technical_committee': technical_committee})
gtest_genesis.update({'sudo_key': sudo_key})
# Add identities bloc
identities_wallets = get_identities_bloc()
identities_wallets = get_identities_and_wallets(opt1)
gtest_genesis.update({'identities': identities_wallets[0]})
# Add wallets bloc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment