kotlin - 实现状态更新的流程,我们是否必须使用 SendTransaction
问题描述
我正在尝试实现状态更新流,那么我如何传递输入状态,我可以为 updation_flow 和问题流创建一个单独的文件,我是否必须使用 SendtransactioFlow 作为子流?
我已经传入输入状态建立交易,不知道是否正确请验证。
将输入状态添加到事务构建器中的事务的代码
// We create a transaction builder and add the components.
val hashasint: Int = serviceHub.vaultService.hashCode()
val convertostring: String = hashasint.toString()
val ourStateRef = StateRef(SecureHash.sha256(convertostring), 0)
val inputState: StateAndRef<KycState> = serviceHub.toStateAndRef(ourStateRef)
val txBuilder = TransactionBuilder(notary = notary)
.addOutputState(outputState, KycContract.ID)
.addCommand(command)
.addInputState(inputState)
用于实现状态更新流程的代码
val signedTx = serviceHub.signInitialTransaction(txBuilder)
// Creating a session with the other party.
val otherPartySession = initiateFlow(otherParty) // i think here is where the actual link to other node starts
subFlow(SendTransactionFlow(otherPartySession,signedTx))
// Obtaining the counterparty's signature.
val fullySignedTx = subFlow(CollectSignaturesFlow(signedTx, listOf(otherPartySession), CollectSignaturesFlow.tracker()))
// We finalise the transaction and then send it to the counterparty.
subFlow(FinalityFlow(fullySignedTx, otherPartySession))
更新流程是否需要使用 SendTransactionFlow。
解决方案
SendTransactionFlow 在 FinalityFlow 中调用。无需单独调用。请参阅下面的链接 -
https://github.com/corda/corda/blob/master/core/src/main/kotlin/net/corda/core/flows/FinalityFlow.kt
另请参阅 SO- Corda 在 finalityFlow 中行走链
推荐阅读
- assembly - 在汇编中编写一个子例程,用 0 替换绝对值大于正值 X 的序列元素
- python - BeautifulSoup4 抓取 URL 不变的页面 [Python]
- javascript - 这个想法是点击标签以显示下拉菜单项
- flutter - 在 Flutter 中更改选项卡时添加进度指示器
- excel - 检查时间是否在vba中的特定范围内
- c# - Xamarin Essentials 连接始终返回蜂窝连接
- hl7-fhir - 暴露给 FHIR 服务器的电子健康记录
- c - 引发 FE_INEXACT 后执行的典型用户定义逻辑是什么?
- sql - 映射到 SQL 中许多顺序子案例的第一个父案例
- reactjs - 有没有办法将 ID 传递给 modal 以呈现每个用户的正确上下文?