def run_node(): ip = '52.37.111.254' cliNodeReg = OrderedDict([ # ('AlphaC', ('127.0.0.1', 8002)), ('AlphaC', (ip, 4002)), ('BetaC', (ip, 4004)), ('GammaC', (ip, 4006)), ('DeltaC', (ip, 4008)) ]) with Looper(debug=False) as looper: # Nodes persist keys when bootstrapping to other nodes and reconnecting # using an ephemeral temporary directory when proving a concept is a # nice way to keep things clean. clientName = 'Joem' # this seed is used by the signer to deterministically generate # a signature verification key that is shared out of band with the # consensus pool seed = b'g034OTmx7qBRtywvCbKhjfALHnsdcJpl' assert len(seed) == 32 signer = SimpleSigner(seed=seed) assert signer.verstr == 'o7z4QmFkNB+mVkFI2BwX0H' \ 'dm1BGhnz8psWnKYIXWTaQ=' client_address = ('0.0.0.0', 8000) tmpdir = os.path.join(tempfile.gettempdir(), "indy_clients", clientName) client = Client(clientName, cliNodeReg, ha=client_address, signer=signer, basedirpath=tmpdir) looper.add(client) # give the client time to connect looper.runFor(3) # a simple message msg = {TXN_TYPE: NYM} # submit the request to the pool request, = client.submit(msg) # allow time for the request to be executed looper.runFor(3) reply, status = client.getReply(request.reqId) print('') print('Reply: {}\n'.format(reply)) print('Status: {}\n'.format(status))
def put_load(): port = genHa()[1] ha = HA('0.0.0.0', port) name = "hello" wallet = Wallet(name) wallet.addIdentifier(signer=DidSigner( seed=b'000000000000000000000000Steward1')) client = Client(name, ha=ha) with Looper(debug=getConfig().LOOPER_DEBUG) as looper: looper.add(client) print('Will send {} reqs in all'.format(numReqs)) requests = sendRandomRequests(wallet, client, numReqs) start = perf_counter() for i in range(0, numReqs, numReqs // splits): print('Will wait for {} now'.format(numReqs // splits)) s = perf_counter() reqs = requests[i:i + numReqs // splits + 1] waitForSufficientRepliesForRequests(looper, client, requests=reqs, customTimeoutPerReq=100, override_timeout_limit=True) print('>>> Got replies for {} requests << in {}'.format( numReqs // splits, perf_counter() - s)) end = perf_counter() print('>>>Total {} in {}<<<'.format(numReqs, end - start)) exit(0)
def sendRandomRequests(wallet: Wallet, client: Client, count: int): print('{} random requests will be sent'.format(count)) for i in range(count): idr, signer = wallet.addIdentifier() idy = Identity(identifier=idr, verkey=signer.verkey) wallet.addTrustAnchoredIdentity(idy) reqs = wallet.preparePending() return client.submitReqs(*reqs)[0]
def createClientAndWalletWithSeed(name, seed, ha=None): if isinstance(seed, str): seed = seed.encode() if not ha: port = genHa()[1] ha = HA('0.0.0.0', port) wallet = Wallet(name) wallet.addIdentifier(signer=DidSigner(seed=seed)) client = Client(name, ha=ha) return client, wallet
def spawnClient(clientName, port, signerSeed, host='0.0.0.0'): clientAddress = HA(host, port) # from plenum.client.request_id_store import FileRequestIdStore # walletFilePath = os.path.join(config.baseDir, "wallet") # print("Storing request ids in {}".format(walletFilePath)) # store = FileRequestIdStore(walletFilePath) # wallet = Wallet(clientName, store) wallet = Wallet(clientName) wallet.addIdentifier(signer=DidSigner(seed=signerSeed)) client = Client(clientName, ha=clientAddress) return client, wallet
def _createClientAndWallet(self): signer = SimpleSigner(seed=self._seed) port = genHa()[1] ha = HA('0.0.0.0', port) self._client = Client(name=signer.identifier, ha=ha) self._wallet = Wallet(name=signer.identifier) self._wallet.addIdentifier(signer=signer) logger.info("Identifier: {}".format(self.identifier)) logger.info("Signer's verkey: {}".format(self.verkey))
def create_client(self, port: int): return Client(name=randomString(6), basedirpath=self.base_dir, ha=('127.0.0.1', port))