은행 계좌의 출력을 입력으로 가져 와서 값을 업데이트했습니다. 그러나 금고의 상태를 "소비"로 업데이트하는 방법을 모르겠습니다. 나는 그것이 flowlogic을 기반으로 자동적으로 일어날 것이라고 생각했다.Vault 상태를 UNCONSUMED/CONSUMED (으)로 전환
은행 노드가 플로우를 시작하고 은행 및 고객 원장 모두에게 커밋합니다. 고객 노드가 다른 플로우를 시작하고 은행의 상태를 입력으로 가져 와서 값을 갱신하고 고객 및 은행 원장 모두에게 새로운 상태로 커밋합니다. 나는이 레벨까지했고 샘플 코드는 아래에있다.
@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()))
}
자, 내 질문은 : "소비"하는 은행의 상태를 변경하는 방법 고객 노드 다음에 입력으로 사용한 것. 따라서 고객 노드는 동일한 은행 상태에 대해 다시 플로우를 시작할 수 없습니다. 이렇게하면 항상 은행이 흐름을 시작하고 고객이 그 흐름에 응답 할 수 있습니다.
올바른 방법으로 설명하지 않은 것 같습니다. 1) 은행 노드가 상태를 생성하고 클라이언트에게 전송합니다 (즉, FinalityFlow를 사용하는 두 원장 모두에서 커밋 됨). 2) 클라이언트 노드 사본은 (UNCONSUMED) 상태로 만들고 값을 수정 한 다음 은행 및 고객의 원장에게 다시 보냅니다. 여기에서 총 2 개의 은행이 고객에게 전달되고 고객은 고객에게 전달됩니다. 이제 내 문제는 : 클라이언트 노드가 두 번째로 흐름을 시작하려고하면 클라이언트가 은행에서 입력하지 않은 입력 상태를 필요로하기 때문에 허용해서는 안됩니다. – Omganesh
은행 노드가 트랜잭션을 수신했는지 확인했습니다. 그러나 나는 입력 상태가 소비 된 것처럼 보지 않습니다. 볼트 상태의 상태를 수동으로 사용하도록 변경하는 방법을 알려주십시오. – Omganesh
상태는 자동 소비로 표시됩니다. 이것은 수동으로하는 일이 아닙니다. 노드가 주어진 상태를 소비하는 트랜잭션을 보자 마자 소비 된 것으로 상태를 표시합니다. – joel