示例#1
0
文件: helper.py 项目: qyynuaa/plenum
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
示例#2
0
文件: helper.py 项目: evernym/plenum
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
示例#3
0
def send_signed_requests(client: Client, signed_reqs: Sequence):
    return client.submitReqs(*signed_reqs)[0]
示例#4
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.
示例#5
0
def sendRandomRequests(wallet: Wallet, client: Client, count: int):
    reqs = [wallet.signOp(randomOperation()) for _ in range(count)]
    return client.submitReqs(*reqs)
示例#6
0
        """
        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))
示例#7
0
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)