Beispiel #1
0
 def print_tokendata(tokenStatus):
     #print token status
     for i in range(0, len(tokenStatus)):
         if (i == 4 or i == 5):
             dt = DatetimeUtil.timestamp_datetime(tokenStatus[i])
             #dt=datetime.datetime.utcfromtimestamp(token_data[i]/1e3)
             print(DatetimeUtil.datetime_string(dt))
             #print(DatetimeUtil.datetime_timestamp(dt))
             #print(token_data[i])
         else:
             print(tokenStatus[i])
Beispiel #2
0
    def print_tokendata(token_data):
        #print token status
        for i in range(0, len(token_data[0])):
            if (i == 3 or i == 4):
                dt = DatetimeUtil.timestamp_datetime(token_data[0][i])
                #dt=datetime.datetime.utcfromtimestamp(token_data[i]/1e3)
                print(DatetimeUtil.datetime_string(dt))
                #print(DatetimeUtil.datetime_timestamp(dt))
                #print(token_data[i])
            else:
                print(token_data[0][i])

        #print delegation status
        for i in range(0, len(token_data[1])):
            print(token_data[1][i])

        #print authprization status
        print(token_data[2])
Beispiel #3
0
    def calculate_blocktime(block_number, curr_blkNum=0):
        #get current block number to search back
        if (curr_blkNum == 0):
            blk_number = web3.eth.blockNumber
        else:
            blk_number = curr_blkNum

        sum_time = 0
        skip_count = 0
        for i in range(0, block_number - 1):
            blk = web3.eth.getBlock(blk_number - i)
            dt = DatetimeUtil.timestamp_datetime(blk.timestamp * 1000)
            #print(DatetimeUtil.datetime_string(dt))
            time_diff = web3.eth.getBlock(
                blk_number - i).timestamp - web3.eth.getBlock(blk_number - i -
                                                              1).timestamp
            if (time_diff > 60):
                skip_count += 1
            else:
                sum_time += time_diff
            #print(time_diff)
        #print(skip_count)
        ave_blocktime = sum_time / (block_number - skip_count)
        return ave_blocktime