Beispiel #1
0
    def _record_finalize(self, state, originator, data):
        txn_data = RecordFinalizePayload()
        txn_data.ParseFromString(data)

        record_addr = Addressing.record_address(txn_data.identifier)

        state_items = self._get(state, [record_addr])

        records = state_items.get(record_addr, RecordContainer())

        # check that the record does not exists
        record = self._find_record(records, txn_data.identifier)
        if record is None:
            raise InvalidTransaction("Record does not exists.")

        owner = record.owners[len(record.owners) - 1]
        if owner.agent_identifier != originator:
            raise InvalidTransaction("Record can only be finalized by owner.")

        custodian = record.custodians[len(record.custodians) - 1]
        if custodian.agent_identifier != originator:
            raise InvalidTransaction(
                "Application can only be finalized when the owner is the " +
                "custodian.")

        # Mark the record as final
        record.final = True

        # send back the updated agents list
        self._set(state, [(record_addr, records)])
Beispiel #2
0
 def record_finalize(self, record_identifier, wait=None):
     addrs = [Addressing.record_address(record_identifier)]
     return self._send_txn(
         SupplyChainPayload.RECORD_FINALIZE,
         RecordFinalizePayload(identifier=record_identifier),
         addrs,
         addrs,
         wait=wait)
Beispiel #3
0
    def finalize_record_tp_process_request(self,
                                           record_id):
        record_addr = Addressing.record_address(record_id)
        agent_pub_key = self.public_key
        agent_addr = Addressing.agent_address(agent_pub_key)
        inputs = [agent_addr, record_addr]
        outputs = [agent_addr, record_addr]

        return self.create_tp_process_request(
            SupplyChainPayload.RECORD_FINALIZE,
            RecordFinalizePayload(identifier=record_id),
            inputs, outputs)