我正在开发Hyperledger composer应用程序,并且想要获取特定客户端的所有交易(participantInvoking)。
这是我在Permission.acl中的代码:
rule ProducerCanReadClientTxHistorian {
description: "Read historian of an client"
participant: "org.hyperledger.composer.system.Participant"
operation: READ
resource: "org.hyperledger.composer.system.HistorianRecord"
action: ALLOW
}
这是查询:
query selectTxOfClientID {
description: "Select all tx of Client x"
statement:
SELECT org.hyperledger.composer.system.HistorianRecord
WHERE (participantInvoking == _$clientId)
}
但是当我通过使用REST API提供利益相关者ID来执行此查询时,它会提供空的响应正文。
您是如何解决的?
screenshot of rest api for input value.
clientId的值为2814,我应该输入其他值(例如“ resource:org.example.Client#2814”)还是其他值?
“ GET / system / historian ”(返回所有历史学家)的响应如下:
{
"$class": "org.hyperledger.composer.system.HistorianRecord",
"transactionId": "4524d8b127be3b2fab008d73228cedf92bfc7cf46ada6e8355070ebbbe83f74e",
"transactionType": "org.example.Tx",
"transactionInvoked": "resource:org.example.Tx#4524d8b127be3b2fa28cedf92bfc7cf46ada6e8355070ebbbe83f74e",
"participantInvoking": "resource:org.example.Client#2814",
"identityUsed": "resource:org.hyperledger.composer.system.Identity#6fe4f7cbc1fce39598fdc1c1afe4d3324466c78ee40f0ab1fa3c",
"eventsEmitted": [
{
"$class": "org.example.TxEvent",
"newTimestamp": "0000000001",
"newProdottoUsato": "resource:org.example.Product#900",
"newCount": 0,
"eventId": "4524d8b127be3b2fd73228cedf92bfc7cf46ada6e8355070ebbbe83f74e#0",
"timestamp": "2019-01-11T11:33:48.129Z"
}
],
"transactionTimestamp": "2019-01-11T11:33:48.129Z"
},