How to show transaction input data in a Hyperledge

2020-03-30 04:40发布

I'm trying to build a Historian Query that will allow me to see Transactions (and their original inputs). I was kind of trying out an idea based on this issue https://github.com/hyperledger/composer/issues/1850, but that was fixed in the Composer Playground. So now I'm wondering how I can achieve this in the REST API without relying on events to hold the transaction input information.

The query I'm using from following the documentation on queries is:

query HistorianRecords {
  description: "Select from HistorianRecords"
  statement: SELECT org.hyperledger.composer.system.HistorianRecord

}

That returns me information like this

  {
    "$class": "org.hyperledger.composer.system.HistorianRecord",
    "transactionId": "c1bcd961-41bb-43a3-b5ee-c1c3694f7736",
    "transactionType": "Transfer",
    "transactionInvoked": "resource:org.hyperledger.composer.system.Transaction#c1bcd961-41bb-43a3-b5ee-c1c3694f7736",
    "eventsEmitted": [],
    "transactionTimestamp": "2017-09-04T07:55:54.405Z"
  }

None of the input information for the transaction displayed.

I'd like to get the information like how the Online Playground displays it, which basically includes the transaction inputs, ie. in the sample network where you input asset and newValue

{
 "$class": "org.acme.sample.SampleTransaction",
 "asset": "resource:org.acme.sample.SampleAsset#a",
 "newValue": "123",
 "transactionId": "0b7aa7b5-ffed-4fe7-9a60-c883085b88e8",
 "timestamp": "2017-09-04T08:50:53.346Z"
}

My network involves the sending of payments from participant to participant, not being able to see who passed how much to who basically renders the blockchain pointless.

How can I do this using the queries?

2条回答
倾城 Initia
2楼-- · 2020-03-30 04:56

So actually, instead of bothering with a query to the Historian, I got this to work using this query

query myTransactions{
  description: "return all transactions made (not system transactions)"
  statement: SELECT org.acme.sample.NAME_OF_TRANSACTION_CLASS

}
查看更多
▲ chillily
3楼-- · 2020-03-30 05:08

correct, that will work, as its querying a Transaction Registry (or registries) direct. Ultimately, you should be able to query through the Historian Registry too - that is, the input to the transaction should be displayed in full in the historian as well. The historical transaction record has a relationship to the Transaction invoked (from the Txn Registry) to find out 'what the change to the asset (say) was' ie a la Playground. Queries are meant add 'value' to Historian as 'the' historical record - eg"query the history of transactions (and what was it that changed) of type x for the period 1 to period 2". On REST support in the Historian feature - we plan on providing REST support for Historian too and this is in the pipeline (will update the answer later when it is released).

查看更多
登录 后发表回答