【发布时间】:2020-01-06 13:51:06
【问题描述】:
IOUIssueFlow 的参数为IOUState state。如creating-an-instance-of-a-class 中所述,我们可以通过崩溃外壳将状态对象提供给流(也尝试不使用美元符号):
flow start IOUIssueFlow$InitiatorFlow state: { amount: $10, lender: "O=ParticipantB, L=New York, C=GB", borrower: "O=ParticipantC, L=Paris, C=FR" }
此语句适用于 Corda-training-template 的 Kotlin 版本,但在 Java 版本中会引发以下错误:
No matching constructor found:
- [net.corda.training.state.IOUState]: Could not parse as a command: Cannot construct instance of `net.corda.training.state.IOUState` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: UNKNOWN; line: -1, column: -1]
虽然我没有使用默认构造函数,但默认构造函数还是应该被this()调用:
@ConstructorForDeserialization
public IOUState(Amount<Currency> amount, Party lender, Party borrower, UniqueIdentifier linearId){
this.amount = amount;
this.lender = lender;
this.borrower = borrower;
this.linearId = linearId;
}
public IOUState(Amount<Currency> amount, Party lender, Party borrower) {
this(amount, lender, borrower, new UniqueIdentifier());
}
在corda-training-template 中发出 IOU 状态的正确语法是什么?
【问题讨论】:
-
这个问题主要是因为注解
@ConstructorForDeserialization,你还需要传递一个linearId,或者只传递一个UUID字符串并在构造函数中创建一个UniqueIdentifier实例。