Corda states data design

50 Views Asked by At

I want to decide a design scenario on data storing using corda states. I like to know the best way to connect stateA with stateB where stateB can be linked with 3 different types.

Option 1:

Say, I have an InsuranceServiceState having

insuranceType: String // values will be "InsuranceTypeA", "InsuranceTypeB"

insuranceTypeData: AbstractInsuranceTypes // eg: Inherited by InsuranceTypeAClass

And we have InsuranceTypeA, InsuranceTypeB child classes inherited from it. So that according to the user input in InsuranceServiceState, any of these subclasses can be inserted to insuranceTypeData field.

Finally once InsuranceAgreementState is created, it will be referring to the StaticPointer of InsuranceServiceState to identify the service used.

Option 2:

No insuranceTypeData: AbstractInsuranceTypes field inside InsuranceServiceState, instead, two new corda states for InsuranceTypeA, InsuranceTypeB where it has InsuranceServiceState linearId for linking.

Now those InsuranceTypeA or InsuranceTypeB values can be updated without being updating the InsuranceServiceState.

Though in order to know the type used at the time of creation of InsuranceAgreementState, we need to add a

StaticPointer<InsuranceTypeA>

inside InsuranceAgreementState.

Which one is the best way to do it? What criteria I should look at?

0

There are 0 best solutions below