Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Corda 无法从ScheduledFlow启动与其他节点的流会话_Corda - Fatal编程技术网

Corda 无法从ScheduledFlow启动与其他节点的流会话

Corda 无法从ScheduledFlow启动与其他节点的流会话,corda,Corda,我正在尝试从ScheduledFlow启动与另一个节点的流会话。以下是Scheduledstate定义: data class State(val a: Party, val b: Party, val instant: Instant, val status: Status, override

我正在尝试从ScheduledFlow启动与另一个节点的流会话。以下是Scheduledstate定义:

data class State(val a: Party,
                         val b: Party,
                         val instant: Instant,
                          val status: Status,
                          override val linearId: UniqueIdentifier = UniqueIdentifier(),
                          override val participants: List<AbstractParty> = listOf(a, b))
: LinearState, SchedulableState {

private val scheduledTime = instant
override fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity? {
    if (status != Status.COMPLETED) {
        return null
    } else {
        return ScheduledActivity(flowLogicRefFactory.create("com.example.flows.StartFlow", thisStateRef), scheduledTime)
    }
}}
@InitiatingFlow
@SchedulableFlow
class StartFlow(val ref: StateRef): FlowLogic<SignedTransaction?>(){

    @Suspendable
    override fun call(): SignedTransaction? {
        val notary = serviceHub.networkMapCache.notaryIdentities[0]
        val stateAndRef = serviceHub.loadState(stateRef = ref)
        val state = stateAndRef.data as State
        if (state.status != State.COMPLETED) {
            throw IllegalArgumentException("Cannot initiate transfer of ownership")
        }

        // Role decider:
        val parties = state.participants.sortedBy { it.owningKey.toBase58String() }
        if (ourIdentity == parties[0]) {
            val tx = TransactionBuilder(notary = notary)

            // add input states
            tx.addInputState(stateAndRef)

            // add output states
            tx.addOutputState(state.copy(status = Status.TRANSFERRED), ContractA.CONTRACT_ID)
            val command = Command(ContractA.Commands.Command1(), listOf(state.a.owningKey, state.b.owningKey))
            tx.addCommand(command)

            tx.verify(serviceHub)

            val partSignedTx = serviceHub.signInitialTransaction(tx)
            val counterparty = serviceHub.identityService.wellKnownPartyFromAnonymous(parties[1]) ?: throw IllegalStateException("Cannot resolve responding party")
            val counterPartySession = initiateFlow(counterparty)
            val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, setOf(counterPartySession)))

            return subFlow(FinalityFlow(fullySignedTx))
        }
        return null
    }
}
StartFlow无法启动与对方的会话,代码卡在那里

如果将状态构造为

State(a, b, Instant.now(), Status.COMPLETED)
StartFlow能够启动与交易对手的会话,一切正常


这里可能有什么问题?

正如Nitesh所报告的,条件检查对于决策角色是不正确的。ourIdentity==参与方[0]应为ourIdentity.owingkey==参与方[0]。owningkey

这是因为参与方[0]属于AbstractParty类型。我们的身份属于聚会类型。AbstractParty覆盖等于以下内容:

State(a, b, Instant.now().plus(10), Status.COMPLETED)
override fun equals(other: Any?): Boolean = 
    other === this || 
    other is AbstractParty && other.owningKey == owningKey

因此,这两个对象被认为是不相等的。

请检查运行启动流的节点和运行响应器流的节点的日志,并在此处发布输出,好吗?我进行了一些密切的调试,并意识到以下条件检查对于确定ourIdentity==parties[0]的角色是不正确的通过将其更改为if ourIdentity.owingkey==参与方[0]。owingkey,使其正常工作