我在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>