示例#1
0
def get_genesis_time():
    base_url = common.api()
    uri = '/eth/v1alpha1/node/genesis'
    url = base_url + uri
    response = http.request('GET', url)
    if response.status == 200:
        response = json.loads(response.data.decode('UTF-8'))
        genesis_time = response.get('genesisTime')
        genesis_datetime_ = datetime.strptime(genesis_time,
                                              "%Y-%m-%dT%H:%M:%SZ")
        genesis_epoch = arrow.get(genesis_datetime_).timestamp

        return genesis_epoch
示例#2
0
import ast 
import time 
import json
import base64
import math
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')))
from client  import client_beacon_chain,client_schlesi,client_validators

import schedule

from flask_app import common,beacon
from flask_app.models import redis_helper, mongo_helper



base_url = common.api()
config = common.get_config()


def validator_crawler(epoch=0, pageToken = '0'):
    try:
        for data in  client_beacon_chain.getChainHeadStream():
            list_validators = client_beacon_chain.ListValidators(epoch=epoch, pageToken=pageToken)
            for data in list_validators.validator_list:
                #todo process validator data here
                total_size = list_validators.total_size
                validators = data.validator
                index = data.index
                public_key = validators.public_key
                pkB64 = base64.b64encode(public_key).decode()
                pkHex = common.decode_public_key(pkB64)