def gen_txn_path(txn, attr_store): txn_type = get_type(txn) if txn_type not in DomainReqHandler.write_types: return None if txn_type == NYM: nym = get_payload_data(txn).get(TARGET_NYM) binary_digest = domain.make_state_path_for_nym(nym) return hexlify(binary_digest).decode() elif txn_type == ATTRIB: attr_data = get_payload_data(txn) if RAW in attr_data or ENC in attr_data: attr_type = RAW if RAW in attr_data else ENC attr = attr_store.get(attr_data[attr_type]) copy_txn = copy.deepcopy(txn) copy_txn[TXN_PAYLOAD][TXN_PAYLOAD_DATA][attr_type] = attr path = domain.prepare_attr_for_state(copy_txn, path_only=True) return path.decode() if HASH in attr_data: path = domain.prepare_attr_for_state(txn, path_only=True) return path.decode() elif txn_type == SCHEMA: path = domain.prepare_schema_for_state(txn, path_only=True) return path.decode() elif txn_type == CLAIM_DEF: path = domain.prepare_claim_def_for_state(txn, path_only=True) return path.decode() elif txn_type == REVOC_REG_DEF: path = domain.prepare_revoc_def_for_state(txn, path_only=True) return path.decode() elif txn_type == REVOC_REG_ENTRY: path = domain.prepare_revoc_reg_entry_for_state(txn, path_only=True) return path.decode()
def gen_txn_path(self, txn): """Return path to state as 'str' type or None""" txn_type = get_type(txn) if txn_type not in self.state_update_handlers: logger.error('Cannot generate id for txn of type {}'.format(txn_type)) return None if txn_type == NYM: nym = get_payload_data(txn).get(TARGET_NYM) binary_digest = domain.make_state_path_for_nym(nym) return hexlify(binary_digest).decode() elif txn_type == ATTRIB: path = domain.prepare_attr_for_state(txn, path_only=True) return path.decode() elif txn_type == SCHEMA: path = domain.prepare_schema_for_state(txn, path_only=True) return path.decode() elif txn_type == CLAIM_DEF: path = domain.prepare_claim_def_for_state(txn, path_only=True) return path.decode() elif txn_type == REVOC_REG_DEF: path = domain.prepare_revoc_def_for_state(txn, path_only=True) return path.decode() elif txn_type == REVOC_REG_ENTRY: path = domain.prepare_revoc_reg_entry_for_state(txn, path_only=True) return path.decode() raise NotImplementedError("path construction is not implemented for type {}".format(txn_type))
def prepare_for_state(result): request_type = result[TYPE] if request_type == GET_REVOC_REG_DEF: return domain.prepare_revoc_def_for_state(result['data']) if request_type == GET_REVOC_REG: return domain.prepare_revoc_reg_entry_accum_for_state(result['data']) if request_type == GET_REVOC_REG_DELTA: return domain.prepare_revoc_reg_entry_accum_for_state(result['data']) raise ValueError("Cannot make state key for " "request of type {}".format(request_type))
def gen_txn_path(txn): txn_type = get_type(txn) if txn_type not in DomainReqHandler.write_types: return None if txn_type == NYM: nym = get_payload_data(txn).get(TARGET_NYM) binary_digest = domain.make_state_path_for_nym(nym) return hexlify(binary_digest).decode() elif txn_type == ATTRIB: _, path, _, _, _ = domain.prepare_attr_for_state(txn) return path.decode() elif txn_type == SCHEMA: path, _ = domain.prepare_schema_for_state(txn) return path.decode() elif txn_type == CLAIM_DEF: path, _ = domain.prepare_claim_def_for_state(txn) return path.decode() elif txn_type == REVOC_REG_DEF: path, _ = domain.prepare_revoc_def_for_state(txn) return path.decode() elif txn_type == REVOC_REG_ENTRY: path, _ = domain.prepare_revoc_reg_entry_for_state(txn) return path.decode()
def _addRevocDef(self, txn) -> None: assert txn[TXN_TYPE] == REVOC_REG_DEF path, value_bytes = domain.prepare_revoc_def_for_state(txn) self.state.set(path, value_bytes)
def _addRevocDef(self, txn, isCommitted=False) -> None: assert get_type(txn) == REVOC_REG_DEF path, value_bytes = domain.prepare_revoc_def_for_state(txn) self.state.set(path, value_bytes)
def update_state(self, txn, prev_result, is_committed=False): self._validate_txn_type(txn) path, value_bytes = domain.prepare_revoc_def_for_state(txn) self.state.set(path, value_bytes)
def gen_state_key(self, txn): self._validate_txn_type(txn) path = domain.prepare_revoc_def_for_state(txn, path_only=True) return path.decode()