We need a logic for the following scenario:
Say for example, we have three parties, Party A, B and C. We have two states, state X and state Y. Party A, and Party B creates multiple X states, Party C can view all these states. At least two of these X states will have similar data. Party C should create state Y by finding and matching two similar X states.
Where should we apply this matching logic(API or Flow)? How to implement this scenario?
It would be best to perform the matching in a flow, where you have access to the full
VaultQuery
API documented here: https://docs.corda.net/api-vault-query.html.How you perform the match depends on what fields you're matching on, and how similar these fields are. Suppose, based on the CorDapp Example (https://github.com/corda/cordapp-example), that we wanted to match
IOUState
s whosevalue
was 3. Then we could write: