从命令行添加资产

时间:2017-09-29 17:52:50

标签: hyperledger-fabric hyperledger hyperledger-composer

我正在使用一组Hyperledger 1.0.2 docker图像和作曲家0.11.3 我使用的练习网络是basic-sample-network,它带有SampleParticipant和SampleAsset。 我可以使用composer参与者添加以及JSON片段从命令行部署参与者。 我没有找到一个等效的命令行方法来将SampleAsset插入资产注册表。当我使用composer-rest-server POST定义SampleAsset的JSON片段时,它返回了以下错误

Error: Peer has rejected transaction '4d2...91f' with cdoe MVCC_READ_CONFLICT

然后我在阅读了关于BatchTimeout和锁定的评论之后重新提交了我没有修改的内容,因为我是婴儿连锁店的单个用户。第二次,REST服务器返回

Error: Failed to add object with ID 'assetId:1' as the object already exists)

我可以验证资产注册表是否已使用作曲家网络列表进行更新:

name:       basic-sample-network
models:
  - org.hyperledger.composer.system
  - org.acme.sample
scripts:
  - lib/sample.js
registries:
  org.acme.sample.SampleAsset:
    id:           org.acme.sample.SampleAsset
    name:         Asset registry for org.acme.sample.SampleAsset
    registryType: Asset
    assets:
      assetId:1:
        $class:  org.acme.sample.SampleAsset
        assetId: assetId:1
        owner:   resource:org.acme.sample.SampleParticipant#Toby
        value:   new value
  org.acme.sample.SampleParticipant:
    id:           org.acme.sample.SampleParticipant
    name:         Participant registry for org.acme.sample.SampleParticipant
    registryType: Participant
    assets:
      Toby:
        $class:        org.acme.sample.SampleParticipant
        participantId: Toby
        firstName:     Tobias
        lastName:      Hunter

为什么这个奇怪的行为来自REST服务器,它抱怨MVCC_READ_CONFLICT但是还插入了记录,是否有一种方法我错过了从命令行插入SampleAsset?

1 个答案:

答案 0 :(得分:1)

嗯...不确定为什么你会收到一个MVCC错误(如你所说,不能像你所显示的那样确实添加的资产)。

<div class="parent"> <div class="child red">Red</div> <div class="child green">Green</div> <div class="child blue">Blue</div> </div>是提交事务的方法(比如)从命令行添加资产 - 文档中的示例(&#39;示例命令&#39;)和下面的另一个:

https://hyperledger.github.io/composer/reference/composer.transaction.submit.html

https://gist.github.com/jt-nti/137a039eb21992136c3f3e54c5c50fa5#file-org-hyperledger-composer-system-addasset-txt

相关问题