我正在使用Hyperledger Composer,我想访问历史记录中'eventsEmitted'数组中的“to”字段:
"eventsEmitted": [
{
"$class": "org.poc.wallet.WalletTransferEvent",
"from": "resource:org.poc.wallet.Wallet#wallet2",
"to": "resource:org.poc.wallet.Wallet#wallet3",
"amount": 100,
"eventId": "7c180da643f418f4bfb40187ccecef7dddd2d3f4ff952ab16fd913bcccedeac2#0",
"timestamp": "2018-06-05T08:04:38.857Z"
}
]
我在我的ACL文件中尝试了这个但是没有触发规则:
rule CustomersSeeHistoryForWalletTransaction {
description: "Customers should be able to see the history of their own transactions only"
participant(p): "org.poc.wallet.Customer"
operation: READ
resource(r): "org.hyperledger.composer.system.HistorianRecord"
condition: (r.eventsEmitted[0].to.owner.getIdentifier() === p.getIdentifier())
action: ALLOW
}
答案 0 :(得分:0)
在此处查看答案 - > how to access the 'eventEmitted' field in transaction history of hyperledger fabric(基于使用trade-network
示例网络中的事件) - 以及此处所述的事件类 - > https://github.com/hyperledger/composer/blob/master/packages/composer-common/lib/system/org.hyperledger.composer.system.cto#L144 -
另请注意,目前为Composer查询创建了一个问题 - 即能够根据事件定义中的自定义事件查询Historian,并在历史数据库的eventsEmitted
数组中包含自定义事件字段以进行搜索 - 请参阅{ {3}}