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')
def processRequest(self, request: Request, frm: str): if self.is_query(request.operation[TXN_TYPE]): self.process_query(request, frm) self.total_read_request_number += 1 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')
def processRequest(self, request: Request, frm: str): if self.is_query(request.operation[TXN_TYPE]): self.process_query(request, frm) self.total_read_request_number += 1 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')
def applyForced(self, req: Request): if req.isForced(): txn = reqToTxn(req) self.upgrader.handleUpgradeTxn(txn) self.poolCfg.handleConfigTxn(txn)