Beispiel #1
0
    hv = Hive(
        node=["https://testnet.hiveitdev.com"],
        custom_chains={
            "TESTNETHF20": {
                'chain_assets': [{
                    "asset": "@@000000013",
                    "symbol": "HBD",
                    "precision": 3,
                    "id": 0
                }, {
                    "asset": "@@000000021",
                    "symbol": "HIVE",
                    "precision": 3,
                    "id": 1
                }, {
                    "asset": "@@000000037",
                    "symbol": "VESTS",
                    "precision": 6,
                    "id": 2
                }],
                'chain_id':
                '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32',
                'min_version':
                '0.20.0',
                'prefix':
                'TST'
            }
        })
    print(hv.get_blockchain_version())
    print(hv.get_config()["HIVE_CHAIN_ID"])
Beispiel #2
0
            "account": "guest123",
            "social_action_comment_update": {
                "permlink": 'just-a-test-post',
                "title": "just a test post",
                "body": "test post body",
            }
        })

    op3 = operations.Vote(
        **{
            'voter': 'guest123',
            'author': 'wlsuser',
            'permlink': 'another-test-post',
            'weight': 10000,
        })

    privateWif = "5K..."
    tx = TransactionBuilder(use_condenser_api=True, hive_instance=wls)
    tx.appendOps(op1)
    tx.appendWif(privateWif)
    tx.sign()
    tx.broadcast()


if __name__ == "__main__":
    # `blocking=True` forces use of broadcast_transaction_synchronous
    wls = Hive(node=["https://pubrpc.whaleshares.io"], blocking=True)
    print(wls.get_blockchain_version())
    print(wls.get_config())
    test_post(wls)
Beispiel #3
0
    threading = False
    thread_num = 16
    nodelist = NodeList()
    nodes = nodelist.get_nodes(normal=True, appbase=True, dev=True)
    t = PrettyTable([
        "node", "10 blockchain minutes", "10000 virtual account op", "version"
    ])
    t.align = "l"
    for node in nodes:
        print("Current node:", node)
        try:
            hv = Hive(node=node, num_retries=3)
            blockchain = Blockchain(hive_instance=hv)
            account = Account("gtg", hive_instance=hv)
            virtual_op_count = account.virtual_op_count()
            blockchain_version = hv.get_blockchain_version()

            last_block_id = 19273700
            last_block = Block(last_block_id, hive_instance=hv)
            startTime = datetime.now()

            stopTime = last_block.time() + timedelta(seconds=how_many_minutes *
                                                     60)
            ltime = time.time()
            cnt = 0
            total_transaction = 0

            start_time = time.time()
            last_node = blockchain.hive.rpc.url

            for entry in blockchain.blocks(start=last_block_id,
Beispiel #4
0
def benchmark_node(node, how_many_minutes=10, how_many_seconds=30):
    block_count = 0
    history_count = 0
    access_time = 0
    follow_time = 0
    blockchain_version = u'0.0.0'
    successful = True
    error_msg = None
    start_total = timer()
    max_batch_size = None
    threading = False
    thread_num = 16

    authorpermvoter = u"@gtg/hive-pressure-4-need-for-speed|gandalf"
    [author, permlink, voter] = resolve_authorpermvoter(authorpermvoter)
    authorperm = construct_authorperm(author, permlink)
    last_block_id = 19273700
    try:
        hv = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30)
        blockchain = Blockchain(hive_instance=hv)
        blockchain_version = hv.get_blockchain_version()

        last_block = Block(last_block_id, hive_instance=hv)

        stopTime = last_block.time() + timedelta(seconds=how_many_minutes * 60)
        total_transaction = 0

        start = timer()
        for entry in blockchain.blocks(start=last_block_id, max_batch_size=max_batch_size, threading=threading, thread_num=thread_num):
            block_no = entry.identifier
            block_count += 1
            if "block" in entry:
                trxs = entry["block"]["transactions"]
            else:
                trxs = entry["transactions"]

            for tx in trxs:
                for op in tx["operations"]:
                    total_transaction += 1
            if "block" in entry:
                block_time = parse_time(entry["block"]["timestamp"])
            else:
                block_time = parse_time(entry["timestamp"])

            if block_time > stopTime:
                last_block_id = block_no
                break
            if timer() - start > how_many_seconds or quit_thread:
                break
    except NumRetriesReached:
        error_msg = 'NumRetriesReached'
        block_count = -1
    except KeyboardInterrupt:
        error_msg = 'KeyboardInterrupt'
        # quit = True
    except Exception as e:
        error_msg = str(e)
        block_count = -1

    try:
        hv = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30)
        account = Account("gtg", hive_instance=hv)
        blockchain_version = hv.get_blockchain_version()

        start = timer()
        for acc_op in account.history_reverse(batch_size=100):
            history_count += 1
            if timer() - start > how_many_seconds or quit_thread:
                break
    except NumRetriesReached:
        error_msg = 'NumRetriesReached'
        history_count = -1
        successful = False
    except KeyboardInterrupt:
        error_msg = 'KeyboardInterrupt'
        history_count = -1
        successful = False
        # quit = True
    except Exception as e:
        error_msg = str(e)
        history_count = -1
        successful = False

    try:
        hv = Hive(node=node, num_retries=3, num_retries_call=3, timeout=30)
        account = Account("gtg", hive_instance=hv)
        blockchain_version = hv.get_blockchain_version()

        start = timer()
        Vote(authorpermvoter, hive_instance=hv)
        stop = timer()
        vote_time = stop - start
        start = timer()
        Comment(authorperm, hive_instance=hv)
        stop = timer()
        comment_time = stop - start
        start = timer()
        Account(author, hive_instance=hv)
        stop = timer()
        account_time = stop - start
        start = timer()
        account.get_followers()
        stop = timer()
        follow_time = stop - start
        access_time = (vote_time + comment_time + account_time + follow_time) / 4.0
    except NumRetriesReached:
        error_msg = 'NumRetriesReached'
        access_time = -1
    except KeyboardInterrupt:
        error_msg = 'KeyboardInterrupt'
        # quit = True
    except Exception as e:
        error_msg = str(e)
        access_time = -1
    return {'successful': successful, 'node': node, 'error': error_msg,
            'total_duration': timer() - start_total, 'block_count': block_count,
            'history_count': history_count, 'access_time': access_time, 'follow_time': follow_time,
            'version': blockchain_version}