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 _addAttr(self, txn) -> None: """ The state trie stores the hash of the whole attribute data at: the did+attribute name if the data is plaintext (RAW) the did+hash(attribute) if the data is encrypted (ENC) If the attribute is HASH, then nothing is stored in attribute store, the trie stores a blank value for the key did+hash """ assert txn[TXN_TYPE] == ATTRIB path, value, hashed_value, value_bytes = domain.prepare_attr_for_state( txn) self.state.set(path, value_bytes) self.attributeStore.set(hashed_value, value)
def _addAttr(self, txn) -> None: """ The state trie stores the hash of the whole attribute data at: the did+attribute name if the data is plaintext (RAW) the did+hash(attribute) if the data is encrypted (ENC) If the attribute is HASH, then nothing is stored in attribute store, the trie stores a blank value for the key did+hash """ assert txn[TXN_TYPE] == ATTRIB attr_type, path, value, hashed_value, value_bytes = domain.prepare_attr_for_state(txn) self.state.set(path, value_bytes) if attr_type != HASH: self.attributeStore.set(hashed_value, value)
def update_state(self, txn, prev_result, is_committed=True) -> None: """ The state trie stores the hash of the whole attribute data at: the did+attribute name if the data is plaintext (RAW) the did+hash(attribute) if the data is encrypted (ENC) If the attribute is HASH, then nothing is stored in attribute store, the trie stores a blank value for the key did+hash """ self._validate_txn_type(txn) attr_type, path, value, hashed_value, value_bytes = domain.prepare_attr_for_state( txn) self.state.set(path, value_bytes) if attr_type != HASH: self.database_manager.attribute_store.set(hashed_value, value)
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 gen_state_key(self, txn): self._validate_txn_type(txn) path = domain.prepare_attr_for_state(txn, path_only=True) return path.decode()