Exemplo n.º 1
0
def profiling(name_list):
    hv = Hive()
    set_shared_hive_instance(hv)
    del hv
    print("start")
    for name in name_list:
        print("account: %s" % (name))
        acc = Account(name)
        max_index = acc.virtual_op_count()
        print(max_index)
        stopTime = datetime(2018, 4, 22, 0, 0, 0)
        hist_elem = None
        for h in acc.history_reverse(stop=stopTime):
            hist_elem = h
        print(hist_elem)
    print("blockchain")
    blockchain_object = Blockchain()
    current_num = blockchain_object.get_current_block_num()
    startBlockNumber = current_num - 20
    endBlockNumber = current_num
    block_elem = None
    for o in blockchain_object.stream(start=startBlockNumber,
                                      stop=endBlockNumber):
        print("block %d" % (o["block_num"]))
        block_elem = o
    print(block_elem)
Exemplo n.º 2
0
    def test_history_reverse2(self):
        hv = self.bts
        account = Account("bhive.app", hive_instance=hv)
        h_list = []
        max_index = account.virtual_op_count()
        for h in account.history_reverse(start=max_index,
                                         stop=max_index - 4,
                                         use_block_num=False,
                                         batch_size=2,
                                         raw_output=False):
            h_list.append(h)
        self.assertEqual(len(h_list), 5)
        for i in range(1, 5):
            self.assertEqual(h_list[i]["index"] - h_list[i - 1]["index"], -1)

        h_list = []
        for h in account.history_reverse(start=max_index,
                                         stop=max_index - 4,
                                         use_block_num=False,
                                         batch_size=6,
                                         raw_output=False):
            h_list.append(h)
        self.assertEqual(len(h_list), 5)
        for i in range(1, 5):
            self.assertEqual(h_list[i]["index"] - h_list[i - 1]["index"], -1)

        h_list = []
        for h in account.history_reverse(start=max_index,
                                         stop=max_index - 4,
                                         use_block_num=False,
                                         batch_size=6,
                                         raw_output=True):
            h_list.append(h)
        self.assertEqual(len(h_list), 5)
        for i in range(1, 5):
            self.assertEqual(h_list[i][0] - h_list[i - 1][0], -1)

        h_list = []
        for h in account.history_reverse(start=max_index,
                                         stop=max_index - 4,
                                         use_block_num=False,
                                         batch_size=2,
                                         raw_output=True):
            h_list.append(h)
        self.assertEqual(len(h_list), 5)
        for i in range(1, 5):
            self.assertEqual(h_list[i][0] - h_list[i - 1][0], -1)
Exemplo n.º 3
0
    max_batch_size = None
    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
 print("hive_acc.get_followers() {}".format(hive_acc.get_followers()))
 # get_following()
 print("bhive_acc.get_following()  {}".format(bhive_acc.get_following()))
 print("hive_acc.get_following() {}".format(hive_acc.get_following()))
 # has_voted()
 print("bhive_acc.has_voted()  {}".format(
     bhive_acc.has_voted("@thecrazygm/api-methods-list-for-appbase")))
 print("hive_acc.has_voted() {}".format(
     hive_acc.has_voted(
         hivePost("@thecrazygm/api-methods-list-for-appbase"))))
 # curation_stats()
 print("bhive_acc.curation_stats()  {}".format(bhive_acc.curation_stats()))
 print("hive_acc.curation_stats() {}".format(hive_acc.curation_stats()))
 # virtual_op_count
 print("bhive_acc.virtual_op_count()  {}".format(
     bhive_acc.virtual_op_count()))
 print("hive_acc.virtual_op_count() {}".format(hive_acc.virtual_op_count()))
 # get_account_votes
 print("bhive_acc.get_account_votes()  {}".format(
     bhive_acc.get_account_votes()))
 print("hive_acc.get_account_votes() {}".format(
     hive_acc.get_account_votes()))
 # get_withdraw_routes
 print("bhive_acc.get_withdraw_routes()  {}".format(
     bhive_acc.get_withdraw_routes()))
 print("hive_acc.get_withdraw_routes() {}".format(
     hive_acc.get_withdraw_routes()))
 # get_conversion_requests
 print("bhive_acc.get_conversion_requests()  {}".format(
     bhive_acc.get_conversion_requests()))
 print("hive_acc.get_conversion_requests() {}".format(
Exemplo n.º 5
0
 # get_following()
 print("bsteem_acc.get_following()  {}".format(bsteem_acc.get_following()))
 print("steem_acc.get_following() {}".format(steem_acc.get_following()))
 # has_voted()
 print("bsteem_acc.has_voted()  {}".format(
     bsteem_acc.has_voted("@thecrazygm/api-methods-list-for-appbase")))
 print("steem_acc.has_voted() {}".format(
     steem_acc.has_voted(
         hivePost("@thecrazygm/api-methods-list-for-appbase"))))
 # curation_stats()
 print("bsteem_acc.curation_stats()  {}".format(
     bsteem_acc.curation_stats()))
 print("steem_acc.curation_stats() {}".format(steem_acc.curation_stats()))
 # virtual_op_count
 print("bsteem_acc.virtual_op_count()  {}".format(
     bsteem_acc.virtual_op_count()))
 print("steem_acc.virtual_op_count() {}".format(
     steem_acc.virtual_op_count()))
 # get_account_votes
 print("bsteem_acc.get_account_votes()  {}".format(
     bsteem_acc.get_account_votes()))
 print("steem_acc.get_account_votes() {}".format(
     steem_acc.get_account_votes()))
 # get_withdraw_routes
 print("bsteem_acc.get_withdraw_routes()  {}".format(
     bsteem_acc.get_withdraw_routes()))
 print("steem_acc.get_withdraw_routes() {}".format(
     steem_acc.get_withdraw_routes()))
 # get_conversion_requests
 print("bsteem_acc.get_conversion_requests()  {}".format(
     bsteem_acc.get_conversion_requests()))