net.corda.core.flows.UnexpectedFlowEndException-C = GB,L =伦敦,O = NodeA上的交易对手流发生内部错误并已终止

时间:2018-11-30 16:19:22

标签: corda

我正在使用Corda的release-v1。

我的应用程序具有三个节点-A,B和C。以下是应用程序中定义的流程-

流程1:A向B和C发送交易请求

流程2:B批准交易请求,对其进行自我签名,从A获得签名并结束交易。

流1正常运行。执行工作流程2时,出现net.corda.core.flows.UnexpectedFlowEndException错误。

节点A的日志显示以下几行,

net.corda.core.flows.UnexpectedFlowEndException: Counterparty flow on C=GB,L=London,O=NodeA had an internal error and has terminated
    at       net.corda.node.services.statemachine.FlowStateMachineImpl.erroredEnd(FlowStateMachineImpl.kt:446)
    at     net.corda.node.services.statemachine.FlowStateMachineImpl.confirmReceiveType(FlowStateMachineImpl.kt:429)

我参考了Flow的WorkflowTransactionBuildTutorial.kt- (https://github.com/corda/corda/blob/release-V1/docs/source/example-code/src/main/kotlin/net/corda/docs/WorkflowTransactionBuildTutorial.kt

1。我正在为工作流程1执行以下代码

val tradeProposal = IOUContract.State(OU( IouId, IouCurrency, IouAmount), serviceHub.myInfo.legalIdentities.first(), nodeB, nodeC).contract.IOUContract"

val IOU_CONTRACT_ID = "net.corda.bgc.contract.IOUContract"

val tx = TransactionBuilder(notary).withItems(
              StateAndContract(tradeProposal, IOU_CONTRACT_ID),                     
Command(IOUContract.Commands.Issue(),listOf(tradeProposal.sender.owningKey)))
              .addAttachment(secHash)

tx.setTimeWindow(serviceHub.clock.instant(), 180.seconds)

val signedTx = serviceHub.signInitialTransaction(tx)
subFlow(FinalityFlow(signedTx, setOf(serviceHub.myInfo.legalIdentities.first(), nodeB, nodeC)))

return signedTx.tx.outRef<IOUContract.State>(0)

此代码可以正常工作。节点B和C都从节点A接收状态为“ NEW”的IOU请求。

2。我正在为工作流程2执行以下代码

用于将签名的交易发送到发起方并等待的代码
   他们的签名以确认

val tx = TransactionBuilder(notary).
            withItems(
                  latestRecord,
                  StateAndContract(newState, IOU_CONTRACT_ID),
                  Command(IOUContract.Commands.Completed(),                              listOf(serviceHub.myInfo.legalIdentities.first().owningKey, latestRecord.state.data.nodeA.owningKey)))

tx.setTimeWindow(serviceHub.clock.instant(), 600.seconds)

val selfSignedTx = serviceHub.signInitialTransaction(tx)

val session = initiateFlow(newState.nodeA)

val allPartySignedTx = session.sendAndReceive<TransactionSignature>(selfSignedTx).unwrap {
val agreedTx = selfSignedTx + it
agreedTx.verifySignaturesExcept(notary.owningKey)
agreedTx.tx.toLedgerTransaction(serviceHub).verify()
agreedTx
}

subFlow(FinalityFlow(allPartySignedTx, setOf(newState.nodeA, newState.nodeB, newState.nodeC)))

return allPartySignedTx.tx.outRef(0)

流程以接收对提案的最终决定

val completeTx = receive<SignedTransaction>(source).unwrap {
it.verifySignaturesExcept(ourIdentity.owningKey, it.tx.notary!!.owningKey)
val ltx = it.toLedgerTransaction(serviceHub, false)
ltx.verify()
val state = ltx.outRef<IOUContract.State>(0)
}
it

val ourSignature = serviceHub.createSignature(completeTx)
send(ourSignature)

但是,以上代码失败,并引发错误net.corda.core.flows.UnexpectedFlowEndException。

请,任何人都可以指导我更正上面的代码 还是将我重定向到与所需工作流程匹配的示例?

2 个答案:

答案 0 :(得分:1)

当您收到以下表格的例外情况:

net.corda.core.flows.UnexpectedFlowEndException: 
    Counterparty flow on C=GB,L=London,O=NodeA had an internal error and has terminated

这意味着交易对手节点(在这种情况下为NodeA)遇到异常。您应该检查交易对手节点的日志。每个节点在/logs文件夹中都有日志。

答案 1 :(得分:0)

谢谢。

在批准流程中,将“发送和接收”功能替换为“ collectsignaturesflow”功能。现在发起方和批准流程都可以正常工作。

已引用链接- https://github.com/corda/cordapp-example/blob/release-V3/kotlin-source/src/main/kotlin/com/example/flow/ExampleFlow.kt