Exemplo n.º 1
0
 def processRequest(self, request: Request, frm: str):
     if request.operation[TXN_TYPE] == GET_NYM:
         self.send_ack_to_client(request.key, frm)
         result = self.reqHandler.handleGetNymReq(request, frm)
         self.transmitToClient(Reply(result), frm)
     elif request.operation[TXN_TYPE] == GET_SCHEMA:
         self.send_ack_to_client(request.key, frm)
         # TODO: `handleGetSchemaReq` should be changed to
         # `get_reply_for_schema_req`, the rationale being that the method
         # is not completely handling the request but fetching a response.
         # Similar reasoning follows for other methods below
         result = self.reqHandler.handleGetSchemaReq(request, frm)
         self.transmitToClient(Reply(result), frm)
     elif request.operation[TXN_TYPE] == GET_ATTR:
         self.send_ack_to_client(request.key, frm)
         result = self.reqHandler.handleGetAttrsReq(request, frm)
         self.transmitToClient(Reply(result), frm)
     elif request.operation[TXN_TYPE] == GET_CLAIM_DEF:
         self.send_ack_to_client(request.key, frm)
         result = self.reqHandler.handleGetClaimDefReq(request, frm)
         self.transmitToClient(Reply(result), frm)
     else:
         # forced request should be processed before consensus
         if request.operation[TXN_TYPE] == POOL_UPGRADE and request.isForced():
             self.configReqHandler.validate(request)
             self.configReqHandler.applyForced(request)
         super().processRequest(request, frm)
Exemplo n.º 2
0
 async def _sendReq(self, op, clbk):
     req = Request(identifier=self.wallet.defaultId, operation=op)
     req = self.wallet.prepReq(req)
     self.client.submitReqs(req)
     try:
         # TODO: Come up with an explanation, why retryWait had to be
         # increases to 1 from .5 to pass some tests and from 1 to 2 to
         # pass some other tests. The client was not getting a chance to
         # service its stack, we need to find a way to stop this starvation.
         resp = await eventually(_ensureReqCompleted,
                                 req.key,
                                 self.client,
                                 clbk,
                                 timeout=20,
                                 retryWait=2)
     except NoConsensusYet:
         raise TimeoutError('Request timed out')
     return resp
Exemplo n.º 3
0
    def requestSchema(self, nym, name, version, sender):
        """
        Used to get a schema from Sovrin
        :param nym: nym that schema is attached to
        :param name: name of schema
        :param version: version of schema
        :return: req object
        """
        operation = {
            TARGET_NYM: nym,
            TXN_TYPE: GET_SCHEMA,
            DATA: {
                NAME: name,
                VERSION: version
            }
        }

        req = Request(sender, operation=operation)
        return self.prepReq(req)
Exemplo n.º 4
0
 def processRequest(self, request: Request, frm: str):
     if request.operation[TXN_TYPE] == GET_NYM:
         self.send_ack_to_client(request.key, frm)
         result = self.reqHandler.handleGetNymReq(request, frm)
         self.transmitToClient(Reply(result), frm)
         self.total_read_request_number += 1
     elif request.operation[TXN_TYPE] == GET_SCHEMA:
         self.send_ack_to_client(request.key, frm)
         # TODO: `handleGetSchemaReq` should be changed to
         # `get_reply_for_schema_req`, the rationale being that the method
         # is not completely handling the request but fetching a response.
         # Similar reasoning follows for other methods below
         result = self.reqHandler.handleGetSchemaReq(request, frm)
         self.transmitToClient(Reply(result), frm)
         self.total_read_request_number += 1
     elif request.operation[TXN_TYPE] == GET_ATTR:
         self.send_ack_to_client(request.key, frm)
         result = self.reqHandler.handleGetAttrsReq(request, frm)
         self.transmitToClient(Reply(result), frm)
         self.total_read_request_number += 1
     elif request.operation[TXN_TYPE] == GET_CLAIM_DEF:
         self.send_ack_to_client(request.key, frm)
         result = self.reqHandler.handleGetClaimDefReq(request, frm)
         self.transmitToClient(Reply(result), frm)
         self.total_read_request_number += 1
     elif request.operation[TXN_TYPE] == GET_TXNS:
         super().processRequest(request, frm)
     else:
         # forced request should be processed before consensus
         if (request.operation[TXN_TYPE] in [POOL_UPGRADE, POOL_CONFIG
                                             ]) and request.isForced():
             self.configReqHandler.validate(request)
             self.configReqHandler.applyForced(request)
         # here we should have write transactions that should be processed
         # only on writable pool
         if self.poolCfg.isWritable() or (request.operation[TXN_TYPE]
                                          in [POOL_UPGRADE, POOL_CONFIG]):
             super().processRequest(request, frm)
         else:
             raise InvalidClientRequest(
                 request.identifier, request.reqId,
                 'Pool is in readonly mode, try again in 60 seconds')
Exemplo n.º 5
0
 def getRequest(self, requestAuthor: Identifier):
     if not self.seqNo:
         return Request(identifier=requestAuthor,
                        operation=self._opForGet())
Exemplo n.º 6
0
 def ledgerRequest(self):
     if self.ledgerStore.isWriting and not self.seqNo:
         assert self.origin is not None
         return Request(identifier=self.origin, operation=self._op())
Exemplo n.º 7
0
 def ledgerRequest(self):
     if not self.seqNo:
         return Request(identifier=self.trustee, operation=self._op())
Exemplo n.º 8
0
 def ledgerRequest(self):
     if not self.seqNo:
         assert self.identifier is not None
         return Request(identifier=self.trustAnchor, operation=self._op())
Exemplo n.º 9
0
 def applyForced(self, req: Request):
     if req.isForced():
         txn = reqToTxn(req)
         self.upgrader.handleUpgradeTxn(txn)
         self.poolCfg.handleConfigTxn(txn)
Exemplo n.º 10
0
 def ledgerRequest(self):
     if not self.seqNo:
         assert self.id is not None
         return Request(identifier=self.steward, operation=self._op())
Exemplo n.º 11
0
 def applyForced(self, req: Request):
     if req.isForced():
         txn = reqToTxn(req)
         self.upgrader.handleUpgradeTxn(txn)