在哪里提供构造函数输入作为错误消息状态?在调度活动时,我不确定StateRef的正确用法。为了测试基本用法,我成功地运行了心跳CorDapp。
ForwardState:
data class ForwardState(val initiator: Party, val acceptor: Party, val asset: String, val deliveryPrice: BigDecimal, val startDate: Instant, val settlementDate: Instant, val buySell: String) : SchedulableState {
override val participants get() = listOf(initiator, acceptor)
override fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity? {
return ScheduledActivity(flowLogicRefFactory.create("com.template.ForwardSettleFlow"), settlementDate)
}ForwardFlow:
@InitiatingFlow
@StartableByRPC
class ForwardFlow(val initiator: Party, val acceptor: Party, val asset: String, val deliveryPrice: BigDecimal,
val startDate: Instant, val settlementDate: Instant, val buySell: String) : FlowLogic<Unit>() {
companion object {
object GENERATING_TRANSACTION : ProgressTracker.Step("Generating transaction")
object SIGNING_TRANSACTION : ProgressTracker.Step("Signing transaction with our private key")
object FINALISING_TRANSACTION : ProgressTracker.Step("Recording transaction") {
override fun childProgressTracker() = FinalityFlow.tracker()
}
fun tracker() = ProgressTracker(
GENERATING_TRANSACTION,
SIGNING_TRANSACTION,
FINALISING_TRANSACTION
)
}
override val progressTracker = tracker()
@Suspendable
override fun call() {
// Adapted from hello world pt 1/2
}
}ForwardSettleFlow:
@InitiatingFlow
@SchedulableFlow
@StartableByRPC
class ForwardSettleFlow(val initiator: Party, val acceptor: Party, val asset: String, val deliveryPrice: BigDecimal,
val startDate: Instant, val settlementDate: Instant, val buySell: String,
val thisStateRef: StateRef) : FlowLogic<Unit>() {
// progress tracker redacted
@Suspendable
override fun call() {
progressTracker.currentStep = GENERATING_TRANSACTION
val input = serviceHub.toStateAndRef<ForwardState>(thisStateRef)
val output = ForwardState(initiator, acceptor, asset, deliveryPrice, startDate, settlementDate, buySell)
val beatCmd = Command(ForwardContract.Commands.Settle(), ourIdentity.owningKey)
val txBuilder = TransactionBuilder(serviceHub.networkMapCache.notaryIdentities.first())
.addInputState(input)
.addOutputState(output, FORWARD_CONTRACT_ID)
.addCommand(beatCmd)
progressTracker.currentStep = SIGNING_TRANSACTION
val signedTx = serviceHub.signInitialTransaction(txBuilder)
progressTracker.currentStep = FINALISING_TRANSACTION
subFlow(FinalityFlow(signedTx))
}
}ForwardFlow启动并具有用于双方签名的Responder。ForwardSettleFlow和Responder到达ForwardSettleFlow和Responder后响应。这个流在类构造函数中接受thisStateRef。测试表明,忽略这一点对错误输出没有任何影响。这一过程有两个流程和两个相应的响应程序。甲方的空壳在FINALISING_TRANSACTION期间在ForwardFlow期间结冰。
rx.exceptions.OnErrorNotImplementedException: A FlowLogicRef cannot be
constructed for FlowLogic of type com.template.ForwardSettleFlow: due
to missing constructor for arguments: [class
net.corda.core.contracts.StateRef]我相信这阻止了活动的发生,包括在没有要求的测试期间,合同是空白的。
发布于 2018-11-05 17:09:47
FlowLogicRefFactory.create()有以下构造函数:
override fun create(flowClass: Class<out FlowLogic<*>>, vararg args: Any?): FlowLogicRef {在FlowLogicRefFactory.create()中调用ForwardState.nextScheduledActivity()时,根本不传递任何参数:
flowLogicRefFactory.create("com.template.ForwardSettleFlow")但是没有使用零参数的ForwardSettleFlow构造函数:
class ForwardSettleFlow(val initiator: Party, val acceptor: Party, val asset: String,
val deliveryPrice: BigDecimal, val startDate: Instant, val settlementDate: Instant,
val buySell: String, val thisStateRef: StateRef) : FlowLogic<Unit>() {因此,您将得到一个“缺少构造函数”异常。要么您需要更新ForwardSettleFlow以获得一个零参数构造函数,要么您需要将一些参数传递给FlowLogicRefFactory.create()。
https://stackoverflow.com/questions/53135018
复制相似问题