we cannot update the installed chaincode for a certain channel, but we can use the chaincode version to distinguish with the newer updated chaincode from older chaincode.To use newly updated chaincode, we have to install the updated chaincode with the new version with same chaincode name as the older chaincode name on a peer:
peer chaincode install -p chaincodedev/chaincode/sacc -n mycc -v 1
See the -v tag in the above command with version 1 and -n tag with c
haincode name.
Then upgrade the chaincode on the channel:
peer chaincode upgrade -n mycc -v 1 -c '{"Args":["a","10"]}' -C myc
See the -v tag again in
above command with version 1, -n tag with c
haincode name and -C tag with channel name on which it is instantiated.
So, once chaincode is installed and upgraded it retains on the channel and we can use newer updated chaincode by upgrading them. When we invoke the chaincode on a peer it will invoke the latest chaincode that is installed on a channel.