如何在使用hyperledger-composer实现的区块链中找到资产交易的历史记录? [英] How do I find the history of transactions for an Asset in a blockchain implemented using hyperledger-composer?

查看:113
本文介绍了如何在使用hyperledger-composer实现的区块链中找到资产交易的历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究最新的超级账本组合程序(V0.13)版本,并建立了一个具有多个角色的网络,每个角色都可以调用区块链中的选定交易.现在,我想查询区块链(历史记录")中已针对特定订单(资产的定义类型)执行的所有交易.

I'm working on the latest rev of hyperledger-composer (V0.13) and have built a network with multiple roles, each of which can invoke selected transactions within the blockchain. I would now like to query the blockchain (?Historian?) for all transactions which have been executed against a specific Order (defined type of asset).

我使用两种不同的方法来提取Historian数据,一次是通过直接API访问historian.getall(),另一次是通过定义的查询:

I've used two different appoaches to pulling Historian data, once through direct API access historian.getall() and the other through a defined query:

query getHistorianRecords {
  description: "get all Historian records"
  statement: SELECT org.hyperledger.composer.system.HistorianRecord

}

两个查询都成功,因为它们返回系统内的所有事务.以前:

Both queries succeed in that they return all transactions within the system. per ex:

ValidatedResource {
    '$modelManager': ModelManager { modelFiles: [Object] },
    '$namespace': 'org.hyperledger.composer.system',
    '$type': 'HistorianRecord',
    '$identifier': '0c3274475fed3703692bb7344453ab0910686905451b41d5d08ff1b032732aa1',
    '$validator': ResourceValidator { options: {} },
    transactionId: '0c3274475fed3703692bb7344453ab0910686905451b41d5d08ff1b032732aa1',
    transactionType: 'org.acme.Z2BTestNetwork.CreateOrder',
    transactionInvoked: 
     Relationship {
       '$modelManager': [Object],
       '$namespace': 'org.acme.Z2BTestNetwork',
       '$type': 'CreateOrder',
       '$identifier': '0c3274475fed3703692bb7344453ab0910686905451b41d5d08ff1b032732aa1',
       '$class': 'Relationship' },
    eventsEmitted: [],
    transactionTimestamp: 2017-09-22T19:32:48.182Z }

我找不到和需要的是一种针对单个订单查询交易历史的方法.订单的定义(部分列出)如下:

What I can't find, and need, is a way to query the history of transactions against a single Order. An Order is defined (partial listing) as follows:

asset Order identified by orderNumber {
    o String orderNumber
    o String[] items
    o String status
    ...
    o String approved
    o String paid
    --> Provider provider
    --> Shipper shipper
    --> Buyer buyer
    --> Seller seller 
    --> FinanceCo financeCo 

我正在寻找一种机制,该机制将允许我查询区块链以获取与Order with orderNumber = '009'有关的每条记录.我可以轻松找到009号订单的当前状态,但现在正在查找针对该订单的交易记录.如何告诉Historian或hyperledger-composer系统中的其他服务,给我该信息?

What I'm looking for is a mechanism that will allow me to query the blockchain to get every record pertaining to an Order with orderNumber = '009'. I can, and have, easily found the current state of Order # 009, but am now looking for the history of transactions against that order. How to I tell Historian, or another service in the hyperledger-composer system, to give me that information?

推荐答案

您试图做的事情完全合情合理,但是Historian尚不支持.在此跟踪此要求: https://github.com/hyperledger/composer/issues/991

What you are trying to do makes total sense, however the Historian doesn't yet support it. This requirement is being tracked here: https://github.com/hyperledger/composer/issues/991

计划将元数据添加到HistorianRecord中,以捕获受交易影响的资产和参与者的ID以及所执行的操作(删除,更新,创建,读取?).

The plan is to add metadata into the HistorianRecord to capture the IDs of the assets and participants that where impacted by the transaction along with the operation performed (delete, update, create, read?).

就位后,您将可以查询引用给定资产/参与者ID的HistorianRecord.

Once that is in place you will be able to query for HistorianRecords that reference a given asset/participant id.

这篇关于如何在使用hyperledger-composer实现的区块链中找到资产交易的历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆