2017-10-28 14:41:13 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# This script will build and start and test chaincode in DEV mode
|
|
|
|
|
|
|
|
if [ -f ./func.sh ]; then
|
|
|
|
source ./func.sh
|
|
|
|
elif [ -f scripts/func.sh ]; then
|
|
|
|
source scripts/func.sh
|
2017-12-15 12:05:12 +08:00
|
|
|
else
|
|
|
|
echo "Cannot find the func.sh files, pls check"
|
|
|
|
exit 1
|
2017-10-28 14:41:13 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo " ============================================== "
|
|
|
|
echo " ==========initialize businesschannel========== "
|
|
|
|
echo " ============================================== "
|
|
|
|
echo
|
|
|
|
|
2017-12-06 16:24:33 +08:00
|
|
|
echo_b "Channel name: "${APP_CHANNEL}
|
2017-10-28 14:41:13 +08:00
|
|
|
|
|
|
|
## Create channel
|
|
|
|
echo_b "Creating channel..."
|
2017-12-12 22:47:40 +08:00
|
|
|
channelCreate ${APP_CHANNEL} ${APP_CHANNEL_TX}
|
2017-10-28 14:41:13 +08:00
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
## Join all the peers to the channel
|
|
|
|
echo_b "Having peer0 join the channel..."
|
2017-12-06 16:24:33 +08:00
|
|
|
channelJoin ${APP_CHANNEL} 0
|
2017-10-28 14:41:13 +08:00
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
## Set the anchor peers for each org in the channel
|
|
|
|
#echo_b "Updating anchor peers for peer0/org1... no use for only single channel"
|
|
|
|
#updateAnchorPeers 0
|
|
|
|
|
|
|
|
# We suppose the binary is there, otherwise, run `go build` under the chaincode path
|
|
|
|
chaincodeStartDev 0 1.0
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
## Install chaincode on all peers
|
|
|
|
echo_b "Installing chaincode on peer0..."
|
|
|
|
chaincodeInstall 0 1.0
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# Instantiate chaincode on all peers
|
|
|
|
# Instantiate can only be executed once on any node
|
|
|
|
echo_b "Instantiating chaincode on the channel..."
|
|
|
|
chaincodeInstantiate 0
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo_g "===================== All GOOD, initialization completed ===================== "
|
|
|
|
echo
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo " _____ _ _ ____ "
|
|
|
|
echo "| ____| | \ | | | _ \ "
|
|
|
|
echo "| _| | \| | | | | |"
|
|
|
|
echo "| |___ | |\ | | |_| |"
|
|
|
|
echo "|_____| |_| \_| |____/ "
|
|
|
|
echo
|
|
|
|
|
|
|
|
exit 0
|