保险柜状态为未清偿/已消耗的状态

问题描述 投票:0回答:1

我已将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 Bank应启动流程,然后客户可以响应该流程。

kotlin corda
1个回答
0
投票

作为FinalityFlow的一部分,交易将发送给交易中所有州的所有参与者(或所有州的所有者,如果他们是OwnableStates)。收到事务后,每个节点将验证它是否有效并完全签名,然后将其记录在其保管库中。此时,节点的保管库将标记消耗的事务的任何输入状态。

如果您在运行流后发现其中一个输入状态未在银行节点上标记为已消耗,则应检查该银行节点是否作为FinalityFlow的一部分接收该事务。

© www.soinside.com 2019 - 2024. All rights reserved.