【解决思路】思路记录

我在github composer上面的提问中找到了issues/4632的一段代码。
他在transaction中没有直接对asset的引用,而我直接对asset引用了。这会不会是我的问题。所以我才无法做一些事情?
以下是我的transaction和event原文。

transaction SampleTransaction {
  --> SampleAsset asset
  --> SampleParticipant newowner
  o String newValue
}

event SampleEvent {
  --> SampleAsset asset
  --> SampleParticipant oldowner
  --> SampleParticipant newowner
  o String oldValue
  o String newValue
}

改成

transaction SampleTransaction {
  -->SampleAsset asset1
  o String newowner
  o String newValue
}

event SampleEvent {
  o String assetId
  o String oldowner
  o String newowner
  o String oldValue
  o String newValue
}

然后试着运行:

// 4. Create an instance of transaction
    let options = {
        generate: false,
        includeOptionalFields: false
    }
    let transaction = factory.newTransaction(namespace,transactionType);

    // 5. Set up the properties of the transaction object
    
    transaction.setPropertyValue('newowner', factory.newRelationship(namespace,'SampleParticipant','0002'));
    transaction.setPropertyValue('newValue' , "newValue");
    transaction.setPropertyValue('asset',factory.newRelationship(namespace,'SampleAsset','00001'));

报错信息让人摸不着头脑,为什么这个代码里面都没有写event为什么会涉及event????:

cielo@cielo-ThinkPad-E550:~/cprogrames/HLF-Fabric-API-master$ node bn-factory-submit-txn.js
2. Received Definition from Runtime:  csupplychain    0.0.1
Error: Error trying invoke business network with transaction id 8286815e6222e353658ae930d981a6d98cd16085f36cfdfc2764279d9d86c3a0. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: transaction returned with failure: ValidationException: Instance org.sc.product.SampleEvent#8286815e6222e353658ae930d981a6d98cd16085f36cfdfc2764279d9d86c3a0#0 missing required field newowner
    at HLFConnection.invokeChainCode (/home/cielo/cprogrames/HLF-Fabric-API-master/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:1117:30)
    at <anonymous>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值