是否可以在流程中动态向状态添加参与方,以便将状态存储在第三方库中,而不需要在ReceiveFinalityFlow中使用StatesToRecord.ALL_VISIBLE?
在Corda 2.0中我们已经实现了同样的功能,但在Corda 4.0中不再适用。
在Corda 3.2及以上版本中是否不支持该功能?我看到在ContractState中添加了@KeepForDJVM。
我尝试在IOUState中动态添加参与方,例如:[iouState.participants.add(thirdParty)]
,并在更新IOUState的参与方列表为可变列表时([override val participants: MutableList<AbstractParty> = mutableListOf(lender, borrower)]
),以使IOUState也存储在ThirdParty vault中。 我还将借款人和第三方的流程会话传递给CollectSigntaureFlow和FinalityFlow。 可是,IOUFlowTests [flow records the correct IOU in both parties' vaults]
失败,提示在thridParty vault中找不到iouState。
IOUState:
@BelongsToContract(IOUContract::class)
data class IOUState(val value: Int,
val lender: Party,
val borrower: Party,
val thirdParty: Party,
override val linearId: UniqueIdentifier = UniqueIdentifier()):
LinearState, QueryableState {
/** The public keys of the involved parties. */
//override val participants: MutableList<AbstractParty> get() = mutableListOf(lender, borrower)
override val participants = mutableListOf(lender, borrower)
ExampleFlow:
var iouState = IOUState(iouValue, serviceHub.myInfo.legalIdentities.first(), otherParty, thirdParty)
iouState.participants.add(thirdParty)
val txCommand = Command(IOUContract.Commands.Create(), iouState.participants.map { it.owningKey })
val counterparties = iouState.participants.map { it as Party }.filter { it.owningKey != ourIdentity.owningKey }.toSet()
counterparties.forEach { p -> flowSessions.add(initiateFlow(p))}
val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, flowSessions, GATHERING_SIGS.childProgressTracker()))
// Stage 5.
progressTracker.currentStep = FINALISING_TRANSACTION
// Notarise and record the transaction in both parties' vaults.
return subFlow(FinalityFlow(fullySignedTx, flowSessions, FINALISING_TRANSACTION.childProgressTracker()))
双方借方和第三方都接收流量并签署交易,但在参与者列表中看不到第三方,并且未存储在第三方保险库中。
我希望第三方应该出现在参与者列表中,同时IOUState也应存储在第三方保险库中。