在成功授权后,我正在尝试进行合同升级,我尝试启动升级流程,但是交易对手遇到了异常。所以我想知道何时/为什么发生这种情况。
使用springboot API
val states = queryUnconsumed<ObligationV1>
// Initiate upgrade contract flow.
states.forEach {
val flowInitiate = services.startFlow({ stateAndRef, upgrade -> ContractUpgradeFlow.Initiate(stateAndRef, upgrade) }, it , ObligationContractV2::class.java)
val resultInitiate = flowInitiate.returnValue.getOrThrow()
}
在ContractUpgradeHandler
// Wouldn't this tx always be of type upgrade tx?
val oldStateAndRef = ourSTX!!.tx.outRef<ContractState>(proposal.stateRef.index)
但是在SignedTransaction.kt
** Returns the contained [WireTransaction], or throws if this is a notary change or contract upgrade transaction. */
val tx: WireTransaction get() = coreTransaction as WireTransaction
[WARN ] 2018-08-20T10:25:03,573Z [Node thread-1] flow.[fe5bf9ea-fafc-40b6-9b51-31caaa4ee513].run - Terminated by unexpected exception {} java.lang.ClassCastException: net.corda.core.transactions.ContractUpgradeWireTransaction cannot be cast to net.corda.core.transactions.WireTransaction at net.corda.core.transactions.SignedTransaction.getTx(SignedTransaction.kt:62) ~[corda-core-corda-3.0.jar:?] at net.corda.node.services.ContractUpgradeHandler.verifyProposal(CoreFlowHandlers.kt:57) ~[corda-node-corda-3.0.jar:?] at net.corda.core.flows.AbstractStateReplacementFlow$Acceptor.call(AbstractStateReplacementFlow.kt:149) ~[corda-core-corda-3.0.jar:?] at net.corda.core.flows.AbstractStateReplacementFlow$Acceptor.call(AbstractStateReplacementFlow.kt:129) ~[corda-core-corda-3.0.jar:?] at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:96) [corda-node-corda-3.0.jar:?] at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:44) [corda-node-corda-3.0.jar:?] at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) [quasar-core-0.7.9-jdk8.jar:0.7.9] at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) [quasar-core-0.7.9-jdk8.jar:0.7.9] at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) [quasar-core-0.7.9-jdk8.jar:0.7.9] at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) [quasar-core-0.7.9-jdk8.jar:0.7.9] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_181] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_181] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_181] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_181] at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:62) [corda-node-corda-3.0.jar:?]
答案 0 :(得分:0)
该错误消息非常直接,似乎您正在尝试将ContractUpgradeWireTransaction
强制转换为WireTransaction
在代码中的某个位置。
这是我们最近的有关如何在Corda上实施合同升级的教程:https://medium.com/corda/contract-upgrades-and-constraints-in-corda-425055a9a47f 这是视频教程:https://www.youtube.com/watch?v=rWyJRaoWNhc