def addNewClient(role, looper, creatorClient: Client, creatorWallet: Wallet, name: str): wallet = Wallet(name) wallet.addIdentifier() idr = wallet.defaultId op = { TXN_TYPE: NYM, ROLE: role, TARGET_NYM: idr, ALIAS: name, VERKEY: wallet.getVerkey(idr) } req = creatorWallet.signOp(op) creatorClient.submitReqs(req) nodeCount = len(creatorClient.nodeReg) looper.run( eventually(checkSufficientRepliesRecvd, creatorClient.inBox, req.reqId, 1, retryWait=1, timeout=3 * nodeCount)) return wallet
def addNewClient(role, looper, creatorClient: Client, creatorWallet: Wallet, name: str): wallet = Wallet(name) wallet.addIdentifier() idr = wallet.defaultId op = { TXN_TYPE: NYM, ROLE: role, TARGET_NYM: idr, ALIAS: name, VERKEY: wallet.getVerkey(idr) } req = creatorWallet.signOp(op) creatorClient.submitReqs(req) nodeCount = len(creatorClient.nodeReg) looper.run(eventually(checkSufficientRepliesRecvd, creatorClient.inBox, req.reqId, 1, retryWait=1, timeout=3 * nodeCount)) return wallet
def send_signed_requests(client: Client, signed_reqs: Sequence): return client.submitReqs(*signed_reqs)[0]
We give the client a little time to connect """ looper.runFor(3) """ Create a simple message. """ msg = {'life_answer': 42} """ Before sending this message to the pool, the message needs to be signed first with a key from the wallet """ request = wallet.signOp(msg, identifier=wallet.defaultId) """ And submit the request to the pool. """ client.submitReqs(request) """ Allow some time for the request to be executed. """ looper.runFor(3) """ Let's get the reply. """ reply, status = client.getReply(request.reqId) """ Check the reply and see if consensus has been reached. """ print("Reply: {}\n".format(reply)) print("Status: {}\n".format(status)) """ See the reply details of a request.
def sendRandomRequests(wallet: Wallet, client: Client, count: int): reqs = [wallet.signOp(randomOperation()) for _ in range(count)] return client.submitReqs(*reqs)
""" Create a simple message. """ msg = {'life_answer': 42} """ Before sending this message to the pool, the message needs to be signed first with a key from the wallet """ request = wallet.signOp(msg, identifier=wallet.defaultId) """ And submit the request to the pool. """ client.submitReqs(request) """ Allow some time for the request to be executed. """ looper.runFor(3) """ Let's get the reply. """ reply, status = client.getReply(request.reqId) """ Check the reply and see if consensus has been reached. """ print("Reply: {}\n".format(reply))
def sendRandomRequests(wallet: Wallet, client: Client, count: int): logger.debug('{} random requests will be sent'.format(count)) reqs = [wallet.signOp(randomOperation()) for _ in range(count)] return client.submitReqs(*reqs)