我如何定义多个响应者流,每个都在不同的 CorDapp 中?
How do I define multiple responder flows, each in a different CorDapp?
在 Corda 中,我想创建几个不同版本的响应程序流,每个版本都由不同的节点使用。
为此,我了解我需要在单独的 CorDapp 中定义每个响应程序流。但是,它们也都需要通过 InitiatedBy
注释依赖于启动流 class。
我如何构造包含响应流的不同实现的 CorDapp,以便它们都依赖于这个公共启动流,而不包括我定义启动流的同一个 CorDapp 中的所有响应流?
您需要先定义包含发起流的CorDapp,然后将此CorDapp 设置为每个包含响应流的CorDapp 的依赖项。有关详细信息,请参阅 https://docs.corda.net/cordapp-build-systems.html#dependencies-on-other-cordapps。
例如,假设CorDapp 1定义了以下启动流程:
@InitiatingFlow
@StartableByRPC
class Initiator : FlowLogic<Unit>() {
...
}
然后你有 CorDapp 2A 它定义了以下响应程序流程:
@InitiatedBy(Initiator::class)
@StartableByRPC
class ResponderA : FlowLogic<Unit>() {
...
}
和 CorDapp 2B 定义了以下响应程序流程:
@InitiatedBy(Initiator::class)
@StartableByRPC
class ResponderB : FlowLogic<Unit>() {
...
}
CorDapp 2A 和 CorDapp 2B 然后需要在它们的 build.gradle 文件中依赖,使这些 CorDapps 依赖于 CorDapp 1,其中定义了启动流程。
嗯,问题来了,
Why owner of CorDapp1 shares their business Flow logic
to other? What if the business wants to keep flow implementation codebase private to them?
我认为项目结构和实现如下:
例如。我有三个派对 PartyA、PartyB、PartyC,每个派对都有自己的 CorDapp 版本。
cordapp-contract-states - 此 CorDapp 包含共享 contract
、states
和 abstract initiating flows
将是counter-parties
用来实现他们的 responder flow logic
。 此 CorDapp 与所有必需的交易对手共享。
@InitiatingFlow
摘要 class CreateTradeBaseFlow : FlowLogic {
}
cordapp-partyA - 这个 CorDapp 包含 FlowLogic
创建交易的实现。
@StartableByRPC
class CreateTradeFlow : CreateTradeBaseFlow {
//Actual implementation of initiator flow goes here...
}
cordapp-partyB - 这个 CorDapp 包含 CreateTradeFlow
的响应流和其他业务特定的流逻辑实现。
@InitiatedBy(CreateTradeBaseFlow::class)
class ResponderPartyB(private val otherSideSession: FlowSession) : FlowLogic<SignedTransaction>() {
//implementation of responder flow goes here...
}
cordapp-partyC - 这个 CorDapp 包含 CreateTradeFlow
的响应流和其他业务特定的流逻辑实现。
@InitiatedBy(CreateTradeBaseFlow::class)
class ResponderPartyC(private val otherSideSession: FlowSession) : FlowLogic<SignedTransaction>() {
//implementation of responder flow goes here...
}
你怎么看?
在 Corda 中,我想创建几个不同版本的响应程序流,每个版本都由不同的节点使用。
为此,我了解我需要在单独的 CorDapp 中定义每个响应程序流。但是,它们也都需要通过 InitiatedBy
注释依赖于启动流 class。
我如何构造包含响应流的不同实现的 CorDapp,以便它们都依赖于这个公共启动流,而不包括我定义启动流的同一个 CorDapp 中的所有响应流?
您需要先定义包含发起流的CorDapp,然后将此CorDapp 设置为每个包含响应流的CorDapp 的依赖项。有关详细信息,请参阅 https://docs.corda.net/cordapp-build-systems.html#dependencies-on-other-cordapps。
例如,假设CorDapp 1定义了以下启动流程:
@InitiatingFlow
@StartableByRPC
class Initiator : FlowLogic<Unit>() {
...
}
然后你有 CorDapp 2A 它定义了以下响应程序流程:
@InitiatedBy(Initiator::class)
@StartableByRPC
class ResponderA : FlowLogic<Unit>() {
...
}
和 CorDapp 2B 定义了以下响应程序流程:
@InitiatedBy(Initiator::class)
@StartableByRPC
class ResponderB : FlowLogic<Unit>() {
...
}
CorDapp 2A 和 CorDapp 2B 然后需要在它们的 build.gradle 文件中依赖,使这些 CorDapps 依赖于 CorDapp 1,其中定义了启动流程。
嗯,问题来了,
Why owner of CorDapp1 shares their business Flow logic to other? What if the business wants to keep flow implementation codebase private to them?
我认为项目结构和实现如下:
例如。我有三个派对 PartyA、PartyB、PartyC,每个派对都有自己的 CorDapp 版本。
cordapp-contract-states - 此 CorDapp 包含共享
contract
、states
和abstract initiating flows
将是counter-parties
用来实现他们的responder flow logic
。 此 CorDapp 与所有必需的交易对手共享。@InitiatingFlow 摘要 class CreateTradeBaseFlow : FlowLogic {
}
cordapp-partyA - 这个 CorDapp 包含
FlowLogic
创建交易的实现。@StartableByRPC class CreateTradeFlow : CreateTradeBaseFlow { //Actual implementation of initiator flow goes here... }
cordapp-partyB - 这个 CorDapp 包含
CreateTradeFlow
的响应流和其他业务特定的流逻辑实现。@InitiatedBy(CreateTradeBaseFlow::class) class ResponderPartyB(private val otherSideSession: FlowSession) : FlowLogic<SignedTransaction>() { //implementation of responder flow goes here... }
cordapp-partyC - 这个 CorDapp 包含
CreateTradeFlow
的响应流和其他业务特定的流逻辑实现。@InitiatedBy(CreateTradeBaseFlow::class) class ResponderPartyC(private val otherSideSession: FlowSession) : FlowLogic<SignedTransaction>() { //implementation of responder flow goes here... }
你怎么看?