【问题标题】:Can a Corda node initiate a flow session with itself?Corda 节点可以与自己发起流会话吗?
【发布时间】:2019-03-27 17:25:15
【问题描述】:

在 Corda 流中,您可以向对方发起 FlowSession 以发送和接收数据。

节点可以自己发起FlowSession吗?

【问题讨论】:

    标签: corda


    【解决方案1】:

    是的,这完全没问题。例如,以下将起作用:

    @InitiatingFlow
    @StartableByRPC
    class Initiator : FlowLogic<Unit>() {
        override val progressTracker = ProgressTracker()
    
        @Suspendable
        override fun call() {
            val selfSession = initiateFlow(ourIdentity)
            selfSession.send("It's me!")
        }
    }
    
    @InitiatedBy(Initiator::class)
    class Responder(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
        @Suspendable
        override fun call() {
            logger.info(counterpartySession.receive<String>().unwrap { it })
        }
    }
    

    【讨论】:

      【解决方案2】:

      从 Corda 4 开始,这将引发异常并显示消息:

      不为本地节点提供流会话。 FinalityFlow 将在本地记录经过公证的交易。

      【讨论】:

        猜你喜欢
        • 2020-06-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-28
        • 2017-12-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多