我已将Bank flow的输出作为输入并更新了值。但我不知道如何将保险库的状态更新为“消费”。我认为这将基于flowlogic自动发生。
银行节点启动了流程并将其提交给银行和客户分类帐。 客户节点启动了另一个流并将Bank的状态作为输入,更新了值并在Customer和Bank分类帐上作为新状态提交。 我已经完成了这个级别,并且低于示例代码。
@Suspendable
override fun call(): SignedTransaction {
// Obtain a reference to the notary we want to use.
val notary = serviceHub.networkMapCache.notaryIdentities[0]
// Stage1.
progressTracker.currentStep = GENERATING_TRANSACTION
// Extract state from ledger as input for Customer node
val criteria = QueryCriteria.VaultQueryCriteria(status = Vault.StateStatus.UNCONSUMED)
val results = serviceHub.vaultService.queryBy<POCState>(criteria)
val pocState = results.states.last().state.data
// Customer reset the approval status
val ourOtherOutputStateVB: POCState = pocState.copy(stateCode = pocStateCodeVB, stateCodeMessage = pocStateStringVB)
// Generate an unsigned transaction.
val txCommand = Command(BankContract.Commands.Create(), pocState.participants.map { it.owningKey })
val txBuilder = TransactionBuilder(notary).withItems(StateAndContract(ourOtherOutputStateVB, POC_CONTRACT_ID), txCommand)
// Stage 2.
progressTracker.currentStep = VERIFYING_TRANSACTION
// Verify that the transaction is valid.
txBuilder.verify(serviceHub)
// Stage 3.
progressTracker.currentStep = SIGNING_TRANSACTION
// Sign the transaction.
val partSignedTx = serviceHub.signInitialTransaction(txBuilder)
// Stage 4.
val otherPartyFlow = initiateFlow(otherParty)
progressTracker.currentStep = GATHERING_SIGS
// Send the state to the counterparty, and receive it back with their signature.
val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, setOf(otherPartyFlow), GATHERING_SIGS.childProgressTracker()))
// Stage 5.
progressTracker.currentStep = FINALISING_TRANSACTION
// Notarise and record the transaction in both parties' vaults.
return subFlow(FinalityFlow(fullySignedTx, FINALISING_TRANSACTION.childProgressTracker()))
}
现在,我的问题是: 在Customer节点将其用作输入之后,如何将Bank的状态更改为“Consumed”。因此,Customer节点无法再为同一Bank状态启动流。这将确保ALWAYS银行应启动流程,然后客户可以响应该流程。
答案 0 :(得分:0)
作为FinalityFlow
的一部分,交易将发送给交易中所有州的所有参与者(或所有州的所有者,如果他们是OwnableState
)。收到事务后,每个节点将验证它是否有效并完全签名,然后将其记录在其保管库中。此时,节点的保管库会将消息中的任何输入状态标记为已消耗。
如果您在运行流后发现其中一个输入状态未在银行节点上标记为已消耗,则应检查该银行节点是否在FinalityFlow
中接收该事务。