import sys import time sys.path.append('../') from ammolite import (Cli, HTTPProvider, Account) frontend = sys.argv[1] #cli = Cli(HTTPProvider("http://192.168.1.111:8080")) cli = Cli(HTTPProvider("http://" + frontend)) willQuery = True blockHeight = 0 queryCount = 0 while willQuery: block = cli.getBlock(-1) print(block['height']) if blockHeight > 0 and block['height'] > blockHeight: willQuery = False print('Cluster is runing.....') else: blockHeight = block['height'] queryCount = queryCount + 1 if queryCount > 5: break time.sleep(5) if willQuery: print('Cluster status error, please contact system administrator.....')
account = Account( "cfac4f5fa828072ba8313b0686f02f576fa0fc8caba947569429e88968577865") raw_tx, tx_hash = account.sign(tx) # print("raw_tx = {}, tx_hash = {}".format(raw_tx, tx_hash)) cli.sendTransactions({tx_hash: raw_tx}) receipt = cli.getTransactionReceipt(tx_hash) example_contract.setAddress(receipt['contractAddress']) tx = example_contract.functions.func1(2).buildTransaction({ 'nonce': 2, 'gas': 200000, 'gasPrice': 100, }) raw_tx, tx_hash = account.sign(tx) cli.sendTransactions({tx_hash: raw_tx}) balance = cli.getBalance("1234567890123456789012345678901234567890", height=1) print('balance = {}'.format(balance)) receipt = cli.getTransactionReceipt("1234567890123456789012345678901234567890") print('receipt = {}'.format(receipt)) block = cli.getBlock(123) print('block = {}'.format(block)) elem = cli.getContainerAt('1234567890123456789012345678901234567890', 'cid', '1', 'array', height=1) print('elem = {}'.format(elem))
continue remains.append(b) num_txs = 0 for b in remains: if b['transactions'] is None or len(b['transactions']) == 0: continue num_txs += len(b['transactions']) return remains, num_txs / 60 frontend = sys.argv[1] cli = Cli(HTTPProvider(frontend)) block = cli.getBlock(-1) height = block['height'] blocks_within_1m = [block] console = Console() max_tps = 0 def create_table(blocks, tps, max_tps) -> Table: table = Table() table.add_column(" Height", justify="right") table.add_column("Transactions", justify="right") table.title = 'TPS: {}(MAX) / {}(1m AVG)'.format(int(max_tps), int(tps)) n = min(5, len(blocks)) for i in range(n): block = blocks[len(blocks) - i - 1]