init_chaincode_dev.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env bash
  2. # This script will build and start and test chaincode in DEV mode
  3. if [ -f ./func.sh ]; then
  4. source ./func.sh
  5. elif [ -f scripts/func.sh ]; then
  6. source scripts/func.sh
  7. else
  8. echo "Cannot find the func.sh files, pls check"
  9. exit 1
  10. fi
  11. echo
  12. echo " ============================================== "
  13. echo " ==========initialize businesschannel========== "
  14. echo " ============================================== "
  15. echo
  16. echo_b "Channel name: "${APP_CHANNEL}
  17. ## Create channel
  18. echo_b "Creating channel..."
  19. channelCreate ${APP_CHANNEL} ${APP_CHANNEL_TX}
  20. sleep 1
  21. ## Join all the peers to the channel
  22. echo_b "Having peer0 join the channel..."
  23. channelJoin ${APP_CHANNEL} 0
  24. sleep 1
  25. ## Set the anchor peers for each org in the channel
  26. #echo_b "Updating anchor peers for peer0/org1... no use for only single channel"
  27. #updateAnchorPeers 0
  28. # We suppose the binary is there, otherwise, run `go build` under the chaincode path
  29. chaincodeStartDev 0 1.0
  30. sleep 1
  31. ## Install chaincode on all peers
  32. echo_b "Installing chaincode on peer0..."
  33. chaincodeInstall 0 1.0
  34. sleep 1
  35. # Instantiate chaincode on all peers
  36. # Instantiate can only be executed once on any node
  37. echo_b "Instantiating chaincode on the channel..."
  38. chaincodeInstantiate 0
  39. sleep 1
  40. echo
  41. echo_g "===================== All GOOD, initialization completed ===================== "
  42. echo
  43. echo
  44. echo " _____ _ _ ____ "
  45. echo "| ____| | \ | | | _ \ "
  46. echo "| _| | \| | | | | |"
  47. echo "| |___ | |\ | | |_| |"
  48. echo "|_____| |_| \_| |____/ "
  49. echo
  50. exit 0