在Corda中,如何在不定义Initiating流的情况下定义InitiatedBy流?
In Corda, how to define an InitiatedBy flow without defining the Initiating flow?
我想创建一个 InitiatedBy
流,它由另一个 CorDapp 中定义的流 class 发起。我没有另一个CorDapp的源文件,是其他公司编写和维护的。
如何在我的 CorDapp 中编写 IntiatedBy
流程,以便它可以由在不同 CorDapp 中定义的启动流程启动?
在 Corda 4 中,您可以通过节点配置指定要使用的响应程序流。参见 https://docs.corda.net/head/flow-overriding.html#overriding-a-flow-via-node-configuration。
在 Corda 3 及更早版本中,您需要创建一个抽象 class,它与将启动您的 InitiatedBy
流程的流程具有相同的完全限定名称:
@InitiatingFlow
@StartableByRPC
abstract class Initiator : FlowLogic<Unit>()
然后在流程的 InitiatedBy
注释中使用此 class:
@InitiatedBy(Initiator::class)
class Responder(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
// TODO: Flow response logic.
}
}
Responder
流现在将响应名称为 Initiator
的任何发起流,而不管另一端的实际 class 是 运行。
我想创建一个 InitiatedBy
流,它由另一个 CorDapp 中定义的流 class 发起。我没有另一个CorDapp的源文件,是其他公司编写和维护的。
如何在我的 CorDapp 中编写 IntiatedBy
流程,以便它可以由在不同 CorDapp 中定义的启动流程启动?
在 Corda 4 中,您可以通过节点配置指定要使用的响应程序流。参见 https://docs.corda.net/head/flow-overriding.html#overriding-a-flow-via-node-configuration。
在 Corda 3 及更早版本中,您需要创建一个抽象 class,它与将启动您的 InitiatedBy
流程的流程具有相同的完全限定名称:
@InitiatingFlow
@StartableByRPC
abstract class Initiator : FlowLogic<Unit>()
然后在流程的 InitiatedBy
注释中使用此 class:
@InitiatedBy(Initiator::class)
class Responder(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
// TODO: Flow response logic.
}
}
Responder
流现在将响应名称为 Initiator
的任何发起流,而不管另一端的实际 class 是 运行。