I am trying to follow along this sample Hyperledger Fabric code: https://github.com/hyperledger/education/tree/master/LFS171x/fabric-material
Initially I replaced ch
when developing chaincode on hyperledger fabric.
1: we have to remove chaincode docker image for testing each change. For Example: name of install chaincode is mycc
#remove container
docker rm -f $(docker ps -aq)
#remove images
docker rmi mycc-0-container id or name
2: you can install chaincode just by changing its name like mycc is currently running then you have to change mycc1 and now you need to use mycc1 and perform your transactions. For Example:
#Already install chaincode has named mycc
#following command will install same chaincode(updated) with chaincodeName
#mycc1
docker exec cli peer chaincode install -n mycc1 -v 0 -p github.com/sacc
Note: now you need to instantiate , invoke and query chaincode with name mycc1.
To make the changes in the chaincode made reflect, following steps were taken: 1. Stop all the containers
docker stop $(docker ps -aq)
docker rm -f $(docker ps -aq)
docker images
One of the output will be this among the other hyperledger binary images.REPOSITORY TAG, IMAGE ID, CREATED, SIZE: dev-peer0.org1.example.com-tuna-app-1.0-b58eb592ed6ced10f52cc063bda0c303a4272089a3f9a99000d921f94b9bae9b, latest, 0919d7c15f0a, 3 minutes ago, 172MB
Delete it using the following command:
docker rmi 0919d7c15f0a
Run the fabric again using ./startFabric.sh, npm install, node registerAdmin.js, node registerUser.js and node server.js. It should work
I would guess you alrwady have version 1.0 installed, thats why its complaining that it already exists. Try it with 1.1 or 2.0 by using -v 2.0
instead of -v 1.0
.
It's pretty tricky once you miss the sequence. As per my knowledge, deployment of a chaincode in HLF is a two step process.
Step 1. Transfer the source code into the peer ( each chaincode gets a chaincode id which approximately is a function of their name, path and version). This gets signed by your keys and transferred to the all the peers you have chosen as target. ( This step by the way, is called installation. )
Step 2. The source code is compiled, with all the vendor libs ( I'm talking about the GoLang chaincode version here, hoping that it would be same for the other ones too.). A docker image is built and a container gets formed with that binary. ( This is the part which is known as instantiation - which also becomes an Upgrade if it's already done earlier. )
In this process, the step 1 would want the chaincode to be unique. If you have installed once, then if you want to send it again, then make sure you have changed the version number to say abc-1.0 to abc-2.0. This will save you at Installation step.
Once your installation is successful, then it's the matter of when to call for an upgrade and when not. If you have run this container earlier, then right step is to upgrade.
Or the other way around is to do what you did. Clean up and start fresh - which works ok for development, but not for production - as your data goes "poof" with that clean up.