IBM-Blockchain-Archive / marbles

WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. The repository will be kept available in read-only mode.
Apache License 2.0
1.02k stars 977 forks source link

How to update chaincode #163

Closed thanhnam72 closed 6 years ago

thanhnam72 commented 7 years ago

I have add some function in file chaincode\src\marbles\marbles.go but server socket can't call these function. I think chaincode not update yet, so I use node upgrade_chaincode.js , but occur error followed:

debug: [fcw] Upgrading Chaincode peer_urls=[grpc://localhost:7051], channel_id=mychannel, chaincode_id=marbles01, chaincode_version=v5, ssl
-target-name-override=null, pem=null, grpc.http2.keepalive_time=300, grpc.keepalive_time_ms=300000, grpc.http2.keepalive_timeout=35, grpc.k
eepalive_timeout_ms=3500, cc_args=[666666]
debug: [fcw] Sending upgrade cc req targets=[grpc.http2.keepalive_time=300, grpc.keepalive_time_ms=300000, grpc.http2.keepalive_timeout=35,
 grpc.keepalive_timeout_ms=3500, grpc.primary_user_agent=grpc-node/1.6.6, _url=grpc://localhost:7051, addr=localhost:7051, , _request_timeo
ut=90000, , _name=null], chaincodeId=marbles01, chaincodeVersion=v5, fcn=init, args=[666666], 0=235, 1=81, 2=119, 3=165, 4=89, 5=21, 6=210,
 7=189, 8=69, 9=117, 10=128, 11=80, 12=175, 13=87, 14=121, 15=125, 16=88, 17=59, 18=190, 19=135, 20=217, 21=79, 22=188, 23=51, _transaction
_id=999161f9cf8878e1b8160cac87785ac0c0a5ac76bc3f3b23b15a948db02534f9
error: [client-utils.js]: sendPeersProposal - Promise is rejected: Error: chaincode error (status: 500, message: could not find chaincode w
ith name 'mychannel')
    at D:\Data\BlockChain\marbles\node_modules\grpc\src\node\src\client.js:554:15
error: [fcw] Failed to obtain endorsement for transaction. code=2,
error: [fcw] Error in upgrade cc catch block object code=2,
---------------------------------------
info: Upgrade done. Errors: parsed=Blockchain network error - could not find chaincode with name 'mychannel'), raw=[code=2, ]
---------------------------------------
thanhnam72 commented 7 years ago

I updated chaincode by change version on file install_chaincode.js and instantiate_chaincode,js, but I want to remove previous version chaincode on peer, can you help me

dshuffma-ibm commented 7 years ago

Fabric does not have any sort of kill/suicide function. The chaincode you instantiated cannot be un-instantiated.

What we can do is stop/kill the chaincode's docker container. You can get the list of running containers on your network with the command docker ps and then stop the chaincode you wish to stop with docker stop <container id here, partial id is fine>. docker stop details

this will end the process running that chaincode, BUT it can and will come back if you send a proposal to that chaincode id/version. this is just how Fabric works. if your goal is to have this chaincode never run again, you should stop its container and don't query/invoke it again.

thanhnam72 commented 7 years ago

thank @dshuffma-ibm