我想调试一个链码,但是默认情况下,npm脚本始终使用链码的1.0版,但是我的版本是1.7,并且不想重新启动环境
答案 0 :(得分:1)
迭戈:执行cc:install:debug,因为否则它将尝试读取您没有的配置文件,因此请先将其打包,然后再打包cc:install:debug,您可能也必须对文件夹名称进行硬编码使用脚本变量,这样您就可以拥有动态的:wink:
$ npm run cc:install:debug -- person-debug1
...
Installed Chaincode person-debug1 version 1.0 at org2
[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --inspect=9990 ./start.js --peer.address localhost:7052`
Debugger listening on ws://127.0.0.1:9990/23f811d2-a16f-4a97-ac57-8a64bde4561a
For help see https://nodejs.org/en/docs/inspector
[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --inspect=9991 ./start.js --peer.address localhost:7152`
Debugger listening on ws://127.0.0.1:9991/713821ef-aa72-441c-850d-f4b0718b8ae5
For help see https://nodejs.org/en/docs/inspector
2019-08-23T22:58:57.212Z info [shim:lib/chaincode.js] Registering with peer localhost:7052 as chaincode "person-debug1:1.0"
2019-08-23T22:58:57.229Z info [shim:lib/chaincode.js] Registering with peer localhost:7152 as chaincode "person-debug1:1.0"
2019-08-23T22:58:57.242Z info [shim:lib/handler.js] Successfully registered with peer node. State transferred to "established"
2019-08-23T22:58:57.246Z info [shim:lib/handler.js] Successfully established communication with peer node. State transferred to "ready"
2019-08-23T22:58:57.255Z info [shim:lib/handler.js] Successfully registered with peer node. State transferred to "established"
2019-08-23T22:58:57.256Z info [shim:lib/handler.js] Successfully established communication with peer node. State transferred to "ready"
Debugger attached.
Debugger attached.
Instantiating Chaincode at org1 for channel ch1
It may take a few minutes depending on the chaincode dependencies
2019-08-23 23:59:05.841 WEST [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-08-23 23:59:05.841 WEST [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
info: [Chaincode] =========== Instantiated Chaincode chaincode ===========
info: [Chaincode] Transaction ID: 6bd7609598c269de4756e1d30da82e4c95195ab909015679eba348b82ba693dc
info: [Chaincode] Args: init,
2019-08-23T22:59:05.877Z info [shim:lib/handler.js] [ch1-6bd76095] Calling chaincode Init() succeeded. Sending COMPLETED message back to peer
Instantiated Chaincode at org1
Found config in package [ { name: 'participant-cc',
version: 'file:./packages/participant-cc',
controller: 'ParticipantController' },
{ name: 'person-cc',
version: 'file:./packages/person-cc',
controller: 'PersonController' },
{ name: '@convector-rest-sample/common',
version: 'file:./packages/common',
controller: 'CommonController' } ]
Found config in package [ { name: 'participant-cc',
version: 'file:./packages/participant-cc',
controller: 'ParticipantController' },
{ name: 'person-cc',
version: 'file:./packages/person-cc',
controller: 'PersonController' },
{ name: '@convector-rest-sample/common',
version: 'file:./packages/common',
controller: 'CommonController' } ]
info: [Chaincode] =========== Invoked Chaincode Chaincode ===========
info: [Chaincode] Transaction ID: 5f84022dcb29f04b182ad96b8439b372dd41e3d870fd4bf1cc2acd81af36db99
info: [Chaincode] Args: person_create,{"id":"1-100-115","firstname":"Pete","lastname":"Doe","username":"peter","password":"12345678","email":"pete.doe@example.com"}
debug: [Chaincode] ============= START : person_create ===========
info: [Chaincode] =========== Invoked Chaincode Chaincode ===========
info: [Chaincode] Transaction ID: 5f84022dcb29f04b182ad96b8439b372dd41e3d870fd4bf1cc2acd81af36db99
info: [Chaincode] Args: person_create,{"id":"1-100-115","firstname":"Pete","lastname":"Doe","username":"peter","password":"12345678","email":"pete.doe@example.com"}
debug: [Chaincode] ============= START : person_create ===========
注意链码名称
person-debug1
,它将在项目的根目录中创建一个具有相同名称的目录,下一次增加编号experson-debug2
否则
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg chaincode with name 'person-debug1' already exists
提示:use npm run cc:package -- person-debug1 org1
也很有用,在安装前检查错误很有用
提示:如果需要对分类帐进行播种,请不要忘记使用person-debug1
链码名称
$ npx hurl invoke person-debug1 participant_register gov "Big Government" -u admin
如果代码更改是按照上述步骤进行的,并且我们已经部署了新的链码并准备在断点处停止,那么您很快就会调用
# change to person-debug2
$ npm run cc:package -- person-debug2 org1
$ npm run cc:install:debug -- person-debug2