def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, keys={"active": wif}, num_retries=10 ) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_crea_instance(cls.bts) cls.bts.set_default_account("test") acc = Account("holger80", crea_instance=cls.bts) n_votes = 0 index = 0 while n_votes == 0: comment = acc.get_feed(limit=30)[::-1][index] votes = comment.get_votes() n_votes = len(votes) index += 1 last_vote = votes[0] cls.authorpermvoter = construct_authorpermvoter(last_vote['author'], last_vote['permlink'], last_vote["voter"]) [author, permlink, voter] = resolve_authorpermvoter(cls.authorpermvoter) cls.author = author cls.permlink = permlink cls.voter = voter cls.authorperm = construct_authorperm(author, permlink)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) node_list = nodelist.get_nodes(exclude_limited=True) cls.bts = Crea(node=node_list, use_condenser=True, nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10) cls.creait = Crea(node="https://nodes.creary.net", nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10) acc = Account("holger80", crea_instance=cls.bts) comment = acc.get_feed(limit=20)[-1] cls.authorperm = comment.authorperm [author, permlink] = resolve_authorperm(cls.authorperm) cls.author = author cls.permlink = permlink cls.category = comment.category cls.title = comment.title
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.node_list = nodelist.get_nodes(exclude_limited=True) # stm = shared_crea_instance() # stm.config.refreshBackup() runner = CliRunner() result = runner.invoke(cli, ['-o', 'set', 'default_vote_weight', '100']) if result.exit_code != 0: raise AssertionError(str(result)) result = runner.invoke(cli, ['-o', 'set', 'default_account', 'crea']) if result.exit_code != 0: raise AssertionError(str(result)) result = runner.invoke(cli, ['-o', 'set', 'nodes', str(cls.node_list)]) if result.exit_code != 0: raise AssertionError(str(result)) result = runner.invoke(cli, ['createwallet', '--wipe'], input="test\ntest\n") if result.exit_code != 0: raise AssertionError(str(result)) result = runner.invoke(cli, ['addkey'], input="test\n" + wif + "\n") if result.exit_code != 0: raise AssertionError(str(result)) result = runner.invoke(cli, ['addkey'], input="test\n" + posting_key + "\n") if result.exit_code != 0: raise AssertionError(str(result)) result = runner.invoke(cli, ['addkey'], input="test\n" + memo_key + "\n") if result.exit_code != 0: raise AssertionError(str(result))
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) crea = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, num_retries=10) set_shared_crea_instance(crea)
def test_nodes_update(self): nodelist = NodeList() all_nodes = nodelist.get_nodes(exclude_limited=False, dev=True, testnet=True) nodelist.update_nodes(crea_instance=self.bts) nodes = nodelist.get_nodes() self.assertIn(nodes[0], all_nodes)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes( normal=True, appbase=True), num_retries=10)) stm = Crea(node=nodelist.get_nodes()) self.ws = CreaWebsocket(urls=stm.rpc.nodes, num_retries=10)
def test_get_nodes(self): nodelist = NodeList() all_nodes = nodelist.get_nodes(exclude_limited=False, dev=True, testnet=True, testnetdev=True) self.assertEqual(len(nodelist) - 15, len(all_nodes)) https_nodes = nodelist.get_nodes(wss=False) self.assertEqual(https_nodes[0][:5], 'https')
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.appbase = Crea( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, bundle=False, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, unsigned=True, data_refresh_time_seconds=900, num_retries=10) cls.account = Account("test", full=True, crea_instance=cls.bts)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, num_retries=10) cls.creait = Crea(node="https://nodes.creary.net", nobroadcast=True, num_retries=10) set_shared_crea_instance(cls.bts)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, unsigned=True, keys={"active": wif}, num_retries=10) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_crea_instance(cls.bts) cls.bts.set_default_account("test")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, num_retries=10) cls.creait = Crea(node="https://nodes.creary.net", nobroadcast=True, use_condenser=False, num_retries=10) set_shared_crea_instance(cls.bts) cls.asset = Asset("CBD") cls.symbol = cls.asset["symbol"] cls.precision = cls.asset["precision"] cls.asset2 = Asset("CREA")
def setUpClass(cls): nodelist = NodeList() stm = Crea(node=nodelist.get_nodes(), nobroadcast=True, num_retries=10, expiration=120) set_shared_crea_instance(stm)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea(node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, keys={"active": wif}, num_retries=10) b = Blockchain(crea_instance=cls.bts) num = b.get_current_block_num() cls.start = num - 25 cls.stop = num # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_crea_instance(cls.bts)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) node_list = nodelist.get_nodes(exclude_limited=True) cls.bts = Crea( node=node_list, nobroadcast=True, bundle=False, unsigned=True, # Overwrite wallet to use this list of wifs only keys={"active": wif}, num_retries=10) cls.account = Account("creabot", crea_instance=cls.bts) set_shared_crea_instance(cls.bts)
def setUpClass(cls): nodelist = NodeList() # stm = shared_crea_instance() # stm.config.refreshBackup() # nodes = nodelist.get_testnet() cls.nodes = nodelist.get_nodes() cls.bts = Crea( node=cls.nodes, nobroadcast=True, num_retries=10, expiration=120, ) # from getpass import getpass # self.bts.wallet.unlock(getpass()) cls.bts.set_default_account("crea") # Test account "crea" cls.active_key = "5Jt2wTfhUt5GkZHV1HYVfkEaJ6XnY8D2iA4qjtK9nnGXAhThM3w" cls.posting_key = "5Jh1Gtu2j4Yi16TfhoDmg8Qj3ULcgRi7A49JXdfUUTVPkaFaRKz" cls.memo_key = "5KPbCuocX26aMxN9CDPdUex4wCbfw9NoT5P7UhcqgDwxXa47bit" # Test account "crea1" cls.active_key1 = "5Jo9SinzpdAiCDLDJVwuN7K5JcusKmzFnHpEAtPoBHaC1B5RDUd" cls.posting_key1 = "5JGNhDXuDLusTR3nbmpWAw4dcmE8WfSM8odzqcQ6mDhJHP8YkQo" cls.memo_key1 = "5KA2ddfAffjfRFoe1UhQjJtKnGsBn9xcsdPQTfMt1fQuErDAkWr" cls.active_private_key_of_crea4 = '5JkZZEUWrDsu3pYF7aknSo7BLJx7VfxB3SaRtQaHhsPouDYjxzi' cls.active_private_key_of_crea5 = '5Hvbm9VjRbd1B3ft8Lm81csaqQudwFwPGdiRKrCmTKcomFS3Z9J'
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, timeout=30, num_retries=30, ) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_crea_instance(cls.bts) cls.bts.set_default_account("test") b = Blockchain(crea_instance=cls.bts) num = b.get_current_block_num() # num = 23346630 cls.start = num - 25 cls.stop = num
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.bts = Crea( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, num_retries=10, timeout=30, use_condenser=False, keys={"active": wif}, ) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_crea_instance(cls.bts) cls.bts.set_default_account("test") b = Blockchain(crea_instance=cls.bts) num = b.get_current_block_num() cls.start = num - 100 cls.stop = num cls.max_batch_size = 1 # appbase does not support batch rpc calls at the momement (internal error)
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(normal=True, appbase=True), num_retries=3)) cls.nodes = nodelist.get_nodes() if "https://nodes.creary.net" in cls.nodes: cls.nodes.remove("https://nodes.creary.net") cls.nodes_creait = ["https://nodes.creary.net"] cls.appbase = Crea(node=cls.nodes, nobroadcast=True, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) cls.rpc = CreaNodeRPC(urls=cls.nodes_creait) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_crea_instance(cls.nodes_creait) cls.appbase.set_default_account("test")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea( node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) node_list = nodelist.get_nodes(exclude_limited=True) cls.stm = Crea(node=node_list, keys={ "active": wif, "owner": wif, "memo": wif }, nobroadcast=True, num_retries=10) cls.creait = Crea(node="https://nodes.creary.net", nobroadcast=True, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) set_shared_crea_instance(cls.stm) cls.stm.set_default_account("test")
def setUpClass(cls): stm = shared_crea_instance() stm.config.refreshBackup() nodelist = NodeList() nodelist.update_nodes(crea_instance=Crea(node=nodelist.get_nodes(exclude_limited=False), num_retries=10)) cls.stm = Crea( node=nodelist.get_nodes(exclude_limited=True), nobroadcast=True, # We want to bundle many operations into a single transaction bundle=True, num_retries=10 # Overwrite wallet to use this list of wifs only ) cls.stm.set_default_account("test") set_shared_crea_instance(cls.stm) # self.stm.newWallet("TestingOneTwoThree") cls.wallet = Wallet(crea_instance=cls.stm) cls.wallet.wipe(True) cls.wallet.newWallet(pwd="TestingOneTwoThree") cls.wallet.unlock(pwd="TestingOneTwoThree") cls.wallet.addPrivateKey(wif)
sys.stdout.write("\r%s" % op['block_num']) opcount += 1 now = time.time() total_duration = now - start_time print(" votes: %d, time %.2f" % (opcount, total_duration)) return opcount, total_duration if __name__ == "__main__": node_setup = 1 threading = True thread_num = 8 timeout = 10 nodes = NodeList() nodes.update_nodes(weights={"block": 1}) node_list = nodes.get_nodes()[:5] vote_result = [] duration = [] stm = Crea(node=node_list, timeout=timeout) b = Blockchain(crea_instance=stm) block = b.get_current_block() block.set_cache_auto_clean(False) opcount, total_duration = stream_votes(stm, threading, thread_num) print("Finished!") block.set_cache_auto_clean(True) cache_len = len(list(block._cache)) start_time = time.time() block.clear_cache_from_expired_items() clear_duration = time.time() - start_time
sys.stdout.write("\r%s" % op['block_num']) opcount += 1 now = time.time() total_duration = now - start_time print(" votes: %d, time %.2f" % (opcount, total_duration)) return opcount, total_duration if __name__ == "__main__": node_setup = 1 threading = True thread_num = 8 timeout = 10 nodes = NodeList() nodes.update_nodes(weights={"block": 1}) node_list_wss = nodes.get_nodes(https=False)[:5] node_list_https = nodes.get_nodes(wss=False)[:5] vote_result = [] duration = [] stm_wss = Crea(node=node_list_wss, timeout=timeout) stm_https = Crea(node=node_list_https, timeout=timeout) print("Without threading wss") opcount_wot_wss, total_duration_wot_wss = stream_votes(stm_wss, False, 8) print("Without threading https") opcount_wot_https, total_duration_wot_https = stream_votes( stm_https, False, 8) if threading: print("\n Threading with %d threads is activated now." % thread_num) stm = Crea(node=node_list_wss, timeout=timeout)
from crea.blockchain import Blockchain from crea.block import Block from crea.crea import Crea from crea.utils import parse_time, formatTimedelta from crea.nodelist import NodeList log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) if __name__ == "__main__": node_setup = 1 how_many_hours = 1 nodes = NodeList() if node_setup == 0: stm = Crea(node=nodes.get_nodes(normal=True, wss=True), num_retries=10) max_batch_size = None threading = False thread_num = 8 elif node_setup == 1: stm = Crea(node=nodes.get_nodes(normal=True, wss=True), num_retries=10) max_batch_size = None threading = True thread_num = 16 elif node_setup == 2: stm = Crea(node=nodes.get_nodes(appbase=False, https=False), num_retries=10) max_batch_size = None threading = True thread_num = 16 blockchain = Blockchain(crea_instance=stm) last_block_id = 19273700
from crea.crea import Crea from crea.utils import parse_time, formatTimedelta from crea.nodelist import NodeList from creaapi.exceptions import NumRetriesReached log = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) if __name__ == "__main__": how_many_minutes = 10 how_many_virtual_op = 10000 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: stm = Crea(node=node, num_retries=3) blockchain = Blockchain(crea_instance=stm) account = Account("gtg", crea_instance=stm) virtual_op_count = account.virtual_op_count() blockchain_version = stm.get_blockchain_version() last_block_id = 19273700 last_block = Block(last_block_id, crea_instance=stm)