kleash
kleash

Reputation: 1319

Storing UniqueIdentifier as a reference to other states

I have a PurchaseOrder state where the primary key would be PurchaseOrderID and SupplierName.

I have another LetterOfCredit state which need to refer the above state so that we can get PurchaseOrder from vault if we have LetterOfCredit state.

Which should be the correct way?

Question 2: If I go with second approach, than is it correct to generate UniqueIdentifier from [external id, id] to query for the state from vault.

Thanks for any help.

Upvotes: 0

Views: 62

Answers (1)

Kid101
Kid101

Reputation: 1470

If your purchaseOrder state is a linear state then it's uniquely identified with it's linearId which happens to be a UniqueIdentifier. Now you can randomly generate the identifier from UniqueIdentifier() or you can pass the externalId (which you would like to use to be in sync with your upstream systems) to it and to get back the uniqueIdentifier use UniqueIdentifier.fromString(externalId) . Go with the 2nd approach and get the UniqueIdentifier from externalId as stated above.

Upvotes: 2

Related Questions