def get_action_from_abi_json(action, abi_json, domain=None, key=None): libevt.init_lib() abi_dict = json.loads(abi_json) try: _bin = abi.json_to_bin(action, abi_json).to_hex_string() except: raise Exception('Invalid abi json', action, abi_json) if action == 'newdomain': return NewDomainAction(abi_dict['name'], _bin) elif action == 'updatedomain': return UpdateDomainAction(abi_dict['name'], _bin) elif action == 'newgroup': return NewGroupAction(abi_dict['name'], _bin) elif action == 'updategroup': return UpdateGroupAction(abi_dict['name'], _bin) elif action == 'issuetoken': return IssueTokenAction(abi_dict['domain'], _bin) elif action == 'transfer': return TransferAction(abi_dict['domain'], abi_dict['name'], _bin) elif action == 'destroytoken': return DestroyTokenAcion(abi_dict['domain'], abi_dict['name'], _bin) elif action == 'addmeta': return AddMetaAction(domain, key, _bin) elif action == 'newfungible': return NewFungibleAction(abi_dict['sym'].split('#')[1], _bin) elif action == 'updfungible': return UpdFungibleAction(abi_dict['sym_id'], _bin) elif action == 'issuefungible': return IssueFungibleAction(abi_dict['number'].split('#')[1], _bin) elif action == 'transferft': return TransferFtAction(abi_dict['number'].split('#')[1], _bin) elif action == 'evt2pevt': return EVT2PEVTAction(abi_dict['number'].split('#')[1], _bin) elif action == 'newsuspend': return NewSuspendAction(abi_dict['name'], _bin) elif action == 'aprvsuspend': return AprvSuspendAction(abi_dict['name'], _bin) elif action == 'cancelsuspend': return CancelSuspendAction(abi_dict['name'], _bin) elif action == 'execsuspend': return ExecSuspendAction(abi_dict['name'], _bin) elif action == 'everipass': return EveripassAction(domain, key, _bin) elif action == 'everipay': return EveripayAction(domain, key, _bin) elif action == 'updsched': return UpdateProducerAction(_bin) elif action == 'prodvote': return ProdvoteAction(abi_dict['key'], _bin) elif action == 'setpsvbonus': return SetpsvbonusAction(abi_dict['sym'].split('#')[1], _bin) elif action == 'newlock': return NewlockAction(abi_dict['name'], _bin) else: raise ActionTypeErrorException
def get_action_from_abi_json(action, abi_json, domain=None, key=None): libevt.init_lib() abi_dict = json.loads(abi_json) try: _bin = abi.json_to_bin(action, abi_json).to_hex_string() except: raise Exception('Invalid abi json', action, abi_json) if action == 'newdomain': return NewDomainAction(abi_dict['name'], _bin) elif action == 'updatedomain': return UpdateDomainAction(abi_dict['name'], _bin) elif action == 'newgroup': return NewGroupAction(abi_dict['name'], _bin) elif action == 'updategroup': return UpdateGroupAction(abi_dict['name'], _bin) elif action == 'issuetoken': return IssueTokenAction(abi_dict['domain'], _bin) elif action == 'transfer': return TransferAction(abi_dict['domain'], abi_dict['name'], _bin) elif action == 'addmeta': return AddMetaAction(domain, key, _bin) elif action == 'newfungible': return NewFungibleAction(abi_dict['sym'].split(',')[1], _bin) elif action == 'updfungible': return UpdFungibleAction(abi_dict['sym'].split(',')[1], _bin) elif action == 'issuefungible': return IssueFungibleAction(abi_dict['number'].split(' ')[1], _bin) elif action == 'transferft': return TransferFtAction(abi_dict['number'].split(' ')[1], _bin) elif action == 'newsuspend': return NewSuspendAction(abi_dict['name'], _bin) elif action == 'aprvsuspend': return AprvSuspendAction(abi_dict['name'], _bin) elif action == 'cancelsuspend': return CancelSuspendAction(abi_dict['name'], _bin) elif action == 'execsuspend': return ExecSuspendAction(abi_dict['name'], _bin) else: raise ActionTypeErrorException
def setUpClass(cls): libevt.init_lib()
import json from pyevt import abi, address, ecc, libevt libevt.init_lib() # Type and Structures class BaseType: def __init__(self, **kwargs): self.kwargs = kwargs def dict(self): return self.kwargs def dumps(self): return json.dumps(self.kwargs) class User: def __init__(self): self.pub_key, self.priv_key = ecc.generate_new_pair() class AuthorizerRef: def __init__(self, _type, key): self.key = key self.type = _type def value(self):
def create(config): f = open('launch.config', 'r') text = f.read() f.close() paras = json.loads(text) producer_number = paras['producer_number'] # the number of the producer nodes_number = paras['nodes_number'] # the number of nodes we run evtd_port_http = paras[ 'evtd_port_http'] # the begin port of nodes port,port+1 .... evtd_port_p2p = paras[ 'evtd_port_p2p'] # the begin port of nodes port,port+1 .... evtd_dir = paras['evtd_dir'] # the data directory of the evtd use_tmpfs = paras['use_tmpfs'] # use the tmpfs or not tmpfs_size = paras['tmpfs_size'] # the memory usage per node client = docker.from_env() print('check and free the container before') free_container('evtd_', client) # network=client.networks.create("evt-net",driver="bridge") # begin the nodes one by one print('begin open the evtd') for i in range(0, nodes_number): # create files in evtd_dir if (not os.path.exists(evtd_dir)): os.mkdir(evtd_dir, 0o755) file = os.path.join(evtd_dir, 'dir_{}'.format(i)) if (os.path.exists(file)): print("Warning: the file before didn't freed ") else: os.mkdir(file, 0o755) # make the command cmd = command('evtd.sh') cmd.add_option('--delete-all-blocks') if (i < producer_number): cmd.add_option('--enable-stale-production') cmd.add_option('--producer-name=evt') libevt.init_lib() pub_key, priv_key = ecc.generate_new_pair() cmd.add_option('--private-key={}'.format(priv_key.to_string())) # cmd.add_option('--private-key=5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3') cmd.add_option('--http-server-address=evtd_{}:{}'.format(i, 8888 + i)) cmd.add_option('--p2p-listen-endpoint=evtd_{}:{}'.format(i, 9876 + i)) # cmd.add_option(('--p2p-peer-address=evtd_{}:{}'.format((i+1)%nodes_number, 9876+(i+1)%nodes_number))) for j in range(0, nodes_number): if (i == j): continue cmd.add_option( ('--p2p-peer-address=evtd_{}:{}'.format(j, 9876 + j))) # break # run the image evtd in container if (not use_tmpfs): print('********evtd {} **************'.format(i)) print('name: evtd_{}'.format(i)) print('nework: evt-net') print('http port: {} /tcp: {}'.format(evtd_port_http + i, 8888 + i)) print('p2p port: {} /tcp: {}'.format(evtd_port_p2p + i, 9876 + i)) print('mount location: {}'.format(file)) print('****************************') container = client.containers.run( image='everitoken/evt:latest', name='evtd_{}'.format(i), command=cmd.get_arguments(), network='evt-net', ports={ '{}'.format(evtd_port_http + i): 8888 + i, '{}/tcp'.format(evtd_port_p2p + i): 9876 + i }, detach=True, volumes={file: { 'bind': '/opt/evtd/data', 'mode': 'rw' }}) else: print('********evtd {} **************'.format(i)) print('name: evtd_{}'.format(i)) print('nework: evt-net') print('http port: {} /tcp: {}'.format(evtd_port_http + i, 8888 + i)) print('p2p port: {} /tcp: {}'.format(evtd_port_p2p + i, 9876 + i)) print('tmpfs use size: {} M'.format(tmpfs_size)) print('****************************') container = client.containers.run( image='everitoken/evt:latest', name='evtd_{}'.format(i), command=cmd.get_arguments(), network='evt-net', ports={ '{}'.format(evtd_port_http + i): 8888 + i, '{}/tcp'.format(evtd_port_p2p + i): 9876 + i }, detach=True, tmpfs={'/opt/evtd/data': 'size=' + str(tmpfs_size) + 'M'} # )