how to add a participant to an existing Corda State, and ensure they receive updates?

时间:2018-02-01 18:13:35

标签: corda state-management

Here's an example scenario:

Party A receives data from Party B before Party B has a Corda node and identity. Party A temporarily manages their shared state, using a temporary string identifier for Party B. When Party B launches a node, Party A needs to update the shared state with B's identity (replace the temp id in the State with a Party reference).

At this point, B should become aware of this State, and receive updates if there are any changes. What's the right way to ensure this last part?

1 个答案:

答案 0 :(得分:2)

You would create a transaction that:

  • Takes an input the shared state where B is identified using the temporary string
  • Has as output the same shared state, but with B identified using a Party object and added to the participants

As a participant, B will then receive the transaction as part of the FinalityFlow.

You'd need to think about how to handle the fact that a field in the state could either be an identifier string or a Party object. Some options:

  • Have two subclasses of the overall state, that differ by this field
  • Have nullable fields in the same
  • Define some type that wraps either an identifier or a Party object