【问题标题】:Adding assets from the command line从命令行添加资产
【发布时间】:2017-09-29 17:52:49
【问题描述】:

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

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 的方法?

【问题讨论】:

    标签: hyperledger-fabric hyperledger hyperledger-composer


    【解决方案1】:

    hmmm .. 不知道为什么会出现 MVCC 错误(正如你所说,与确实添加的资产无关,正如你所展示的那样)。

    composer transaction submit 是提交交易以(例如)从命令行添加资产的方法 - 文档中的示例(“示例命令”)和下面的另一个:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      • 2015-12-14
      相关资源
      最近更新 更多