我正在尝试使商业论文教程适应定制合同。更改合同名称后,就无法实例化它。
在商业文件/组织/ magnetocorp / contract / lib中,我更新了paper.js来替换:
static getClass() {
return 'org.papernet.commercialpaper';
}
...和
static getClass() {
return 'org.papernet.commercialpapertest';
}
类似地,在商业文件/组织/ magnetocorp / contract / lib中,我更新了papercontract.js来替换:
constructor() {
// Unique name when multiple contracts per chaincode file
super('org.papernet.commercialpaper');
}
...和:
constructor() {
// Unique name when multiple contracts per chaincode file
super('org.papernet.commercialpapertest');
}
然后,我从以下位置更改了实例化命令:
docker exec cliMagnetoCorp peer chaincode instantiate -n papercontract -v 0 -l node -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' -C mychannel -P "AND ('Org1MSP.member')"
...到:
docker exec cliMagnetoCorp peer chaincode instantiate -n papercontract -v 0 -l node -c '{"Args":["org.papernet.commercialpapertest:instantiate"]}' -C mychannel -P "AND ('Org1MSP.member')"
在删除couchdb数据库,停止然后删除所有容器以及从头重新运行该示例时,这些更改导致实例化失败,并显示Contract name is not known
:
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg transaction returned with failure: Error: Contract name is not known: org.papernet.commercialpapertest
这是docker日志:
> papercontract@0.0.3 start /usr/local/src
> fabric-chaincode-node start "--peer.address" "peer0.org1.example.com:7052"
2019-09-08T16:11:08.911Z info [shim:contracts-spi/bootstrap.js]
No metadata file supplied in contract, introspection will generate all the data
2019-09-08T16:11:08.914Z info [shim:contracts-spi/chaincodefromcontract.js]
Using serializers {"transaction":"jsonSerializer","serializers":{}}
2019-09-08T16:11:08.942Z info [shim:lib/chaincode.js]
Registering with peer peer0.org1.example.com:7052 as chaincode "papercontract:0"
Command succeeded
2019-09-08T16:11:08.971Z info [shim:lib/handler.js] Successfully registered with peer node. State transferred to "established"
2019-09-08T16:11:08.972Z info [shim:lib/handler.js] Successfully established communication with peer node. State transferred to "ready"
2019-09-08T16:11:08.977Z error [shim:contracts-spi/chaincodefromcontract.js [mychannel-971a76f9] Error: Contract name is not known: org.papernet.commercialpapertest
2019-09-08T16:11:08.977Z error [shim:lib/handler.js] [mychannel-971a76f9] Calling chaincode Init() returned error response [Error: Contract name is not known: org.papernet.commercialpapertest]. Sending ERROR message back to peer
列出已安装的合同表明已安装合同:
Get installed chaincodes on peer:
Name: papercontract, Version: 0, Path: /opt/gopath/src/github.com/contract, Id: a766e52585dbf1c0c9b725a72e66bd0e3f50f83da8641c9a4b4d6aebd6b85777
列出已实例化的合同表明未实例化:
Get instantiated chaincodes on channel mychannel:
似乎原始合同名称也设置在其他位置?如果是这样,我无法通过VS Code中的“查找文件”搜索来找到它。
非常感谢您的帮助。
答案 0 :(得分:0)
似乎您没有更改package.json papercontract
中的合同名称,因为该合同已安装在对等方上,并具有详细名称:papercontract, Version: 0