示例#1
0
def test_net_is_working(urls):
    url_index = -1
    for i in (0, len(urls) - 1):
        ce = Cleos(url=urls[i])
        try:
            info = ce.get_info()
            # print(info)
            if info != None:
                url_index = i
                break
        except Exception as err:
            print(err)
    return url_index
示例#2
0
    'a': 11,
    'b': 11,
    'c': 12,
    'd': 12,
    'e': 13,
    'f': 13
}

while 1:
    now = datetime.now()

    while now.second != 0:
        time.sleep(0.1)
        now = datetime.now()

    resp = ce.get_info()
    blockTime = resp['head_block_time']
    blockNum = resp['head_block_num']
    lhdStr = resp['head_block_id'][-2:]

    #print(blockNum, blockTime, lhdStr)

    if blockT(blockTime) != 0:
        newBlockNum = blockNum - 1
        respNew = ce.get_block(newBlockNum)
        newBlockTime = respNew['timestamp']

        #print(newBlockNum, newBlockTime, lhdStr)

        while blockT(newBlockTime) < blockT(blockTime):
            blockNum = newBlockNum
示例#3
0
    labels = nx.draw_networkx_labels(G, pos, node_labels)

    plt.show(figure)

def tonodes(table):
    nodes = {}
    for entry in table['rows']:
        next_node = Node(entry)
        nodes[entry['identity']] = next_node
    if len(nodes) == 0:
        logger.info('table is empty, check your eosurl is correct.')
        return
    return nodes

if __name__ == "__main__":
    args = parser.parse_args()
    cleos = Cleos(url=args.eosurl)
    if args.command == "info":
        logger.info(cleos.get_info())
    elif args.command == "print":
        cleos.get_info()
        table = cleos.get_table('bittensoracc', 'bittensoracc', 'metagraph')
        logger.info(tonodes(table))
    elif args.command == "table":
        cleos.get_info()
        table = cleos.get_table('bittensoracc', 'bittensoracc', 'metagraph')
        nodes = tonodes(table)
        _make_plot_table(nodes)
    else:
        logger.info('Command not found.')
示例#4
0
from eospy.cleos import Cleos

ce = Cleos(url='https://api.eosargentina.io')

# Get info
get_info = ce.get_info()
print(get_info)

# Get head block number from info
head = get_info['head_block_num']
print('Head Block number is', head)