corda - 如何在 Corda 的新状态创建流程中设置启动器?
问题描述
我正在使用 Corda 中的事件调度功能。我在一个州添加了相同的内容。现在我想在现有状态被接受时自动创建另一个状态。接受功能与一方有关,而触发创建另一个状态的动作必须与另一方本身有关。当我尝试这样做时,两个启动器都是相同的。创建新状态流时如何设置对方为发起者?
PS:我们正在遵循一个项目结构,该结构具有用于合同状态和流程的单独模块。
解决方案
实现这一目标的一种方法是:
- 定义一个流,而不是执行任何逻辑,而是简单地交给响应者流
- 定义执行逻辑的响应程序流
这是一个例子:
@InitiatingFlow
@SchedulableFlow
class InitiatorFlow(val counterparty: Party) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
// We send a flag message to the counterparty, causing them to start their responder flow.
val session = initiateFlow(counterparty)
session.send(true)
}
}
@InitiatedBy(InitiatorFlow::class)
class InitiatedFlow(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
// We process and discard the flag message.
counterpartySession.receive<Boolean>()
// TODO: Create the new state based on the acceptance.
}
}
推荐阅读
- python - 如何提取给定单词或句子的颜色
- javascript - 跟随链接后如何返回动态重建表中的起始位置?
- angular - Ionic 3 Calendar,在选择时捕捉更改的日期
- azure - Azure 流分析复杂查询未返回所需结果
- php - 使用 laravel 5.6 为多个字段创建单个 mutator
- botframework - Microsoft Web App Bot 图标未更改
- ios - iOS代码签名错误
- select - 避免 SQL Server 中的重复
- java - ND4J JUnit 测试异常
- asp.net - NuGet 推送版本 3.1.2 返回 405 HTTP 错误(方法不允许)