简体   繁体   中英

Deleting ChainCode from peer

I made a mistake my chaincode and installed them on the peers on my network. When I tried to instantiate the chaincode in the channels, I found the error.

  1. Is there a way to debug chaincode before installing it on peers ? It seems to only get flagged when you instantiate it.
  2. Is there a way to delete the chaincode from the peers without having to restart the network?
  1. Depends on what you mean by mistake / debug. You should make sure it compiles first. That eliminates all typos, syntax, missing libraries, etc. But there is no way to debug functionality except to install and instantiate.

  2. Technically, no. You can delete all the storage (/var/hyperledger/production/peer, /var/hyperledger/production/orderer, the kafka/zookeeper files, and CouchDB). Not a real big deal, but you do have to restart the network and recreate the channel, join it, install and instantiate the cc, etc. But you can install as a different name. Just change the name in your app connection definition to match. You can also upgrade by changing the version number but keeping the same name.

I just change the name until I get to a fairly settled spot and then do the deletes and restart all to clean up. A full cleanup (4 peers, 3 orderers, 4 kafka,3 zoopkeeper) takes me maybe 30 minutes. Normally, I keep a CLI open with install ccname1 and instantiate ccname1 in the buffer and can easily increment to ccname2,3,4,5. It only takes a few seconds that way.

If the error is (chaincode is already present in the peers)

You can try installing the chain code with different version number or different chain code name.

You can initiate chaincode in the channel only once. Next time you have to follow the procedure of upgrade chaincode steps.

Note : Before installing chain code you can check the syntax errors form the machine by installing go and compile the chain code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM