【发布时间】:2018-04-06 11:02:01
【问题描述】:
我对如何在 Hyperledger Composer .cto 文件中定义关系感到有些困惑。请在下面查看我的具体问题:
我在这里粘贴了 .cto 文件的部分内容https://github.com/IBM/Decentralized-Energy-Composer/blob/master/models/model.cto:
participant Resident identified by residentID {
o String residentID
o String firstName
o String lastName
--> Coins coins
--> Cash cash
--> Energy energy
}
asset Coins identified by coinsID {
o String coinsID
o Double value
o String ownerID
o OwnerEntity ownerEntity
}
asset Energy identified by energyID {
o String energyID
o String units
o Double value
o String ownerID
o OwnerEntity ownerEntity
}
asset Cash identified by cashID {
o String cashID
o String currency
o Double value
o String ownerID
o OwnerEntity ownerEntity
}
这应该读作a Resident owns assets which are Coins, Cash and Energy 吗?可以反过来写吗(见下文)?
participant Resident identified by residentID {
o String residentID
o String firstName
o String lastName
}
asset Coins identified by coinsID {
o String coinsID
o Double value
-->Resident owner
}
asset Energy identified by energyID {
o String energyID
o String units
o Double value
--> Resident owner
}
asset Cash identified by cashID {
o String cashID
o String currency
o Double value
--> Resident owner
}
所以,这基本上是说每项资产都归某人所有。哪种设计被认为更好,为什么?请解释一下。
【问题讨论】: