docker-compose-files/hyperledger_fabric/v1.0.2/scripts/init_chaincode_dev.sh

68 lines
1.5 KiB
Bash
Raw Normal View History

2018-01-03 21:19:09 +08:00
#!/usr/bin/env bash
# This script will build and start and test chaincode in DEV mode
2017-09-01 20:09:18 +08:00
if [ -f ./func.sh ]; then
source ./func.sh
elif [ -f scripts/func.sh ]; then
source scripts/func.sh
2018-01-03 21:19:09 +08:00
else
echo "Cannot find the func.sh files, pls check"
exit 1
2017-09-01 20:09:18 +08:00
fi
echo
echo " ============================================== "
echo " ==========initialize businesschannel========== "
echo " ============================================== "
echo
2018-01-03 21:19:09 +08:00
echo_b "Channel name: "${APP_CHANNEL}
2017-09-01 20:09:18 +08:00
## Create channel
echo_b "Creating channel..."
2018-01-03 21:19:09 +08:00
channelCreate ${APP_CHANNEL} ${APP_CHANNEL_TX}
sleep 1
2017-09-01 20:09:18 +08:00
## Join all the peers to the channel
2018-01-03 21:19:09 +08:00
echo_b "Having peer0 join the channel..."
channelJoin ${APP_CHANNEL} 0
2017-09-01 20:09:18 +08:00
2018-01-03 21:19:09 +08:00
sleep 1
2017-09-01 20:09:18 +08:00
## Set the anchor peers for each org in the channel
2018-01-03 21:19:09 +08:00
#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
2017-09-01 20:09:18 +08:00
## Install chaincode on all peers
2018-01-03 21:19:09 +08:00
echo_b "Installing chaincode on peer0..."
2017-09-22 15:16:19 +08:00
chaincodeInstall 0 1.0
2018-01-03 21:19:09 +08:00
sleep 1
2017-09-01 20:09:18 +08:00
# Instantiate chaincode on all peers
# Instantiate can only be executed once on any node
2018-01-03 21:19:09 +08:00
echo_b "Instantiating chaincode on the channel..."
2017-09-22 15:16:19 +08:00
chaincodeInstantiate 0
2018-01-03 21:19:09 +08:00
sleep 1
2017-09-01 20:09:18 +08:00
echo
echo_g "===================== All GOOD, initialization completed ===================== "
echo
echo
echo " _____ _ _ ____ "
echo "| ____| | \ | | | _ \ "
echo "| _| | \| | | | | |"
echo "| |___ | |\ | | |_| |"
echo "|_____| |_| \_| |____/ "
echo
exit 0