docker-compose-files/hyperledger_fabric/latest/scripts/initialize_peer0.sh

41 lines
1.2 KiB
Bash
Raw Normal View History

2017-09-01 20:09:18 +08:00
#!/bin/bash
# Importing useful functions for cc testing
if [ -f ./func.sh ]; then
2021-03-04 06:06:06 +08:00
source ./func.sh
2017-09-01 20:09:18 +08:00
elif [ -f scripts/func.sh ]; then
2021-03-04 06:06:06 +08:00
source scripts/func.sh
2017-09-01 20:09:18 +08:00
fi
2017-12-06 16:24:33 +08:00
echo_b " ========== Network initialization start ========== "
2017-09-01 20:09:18 +08:00
## Create channel
echo_b "Creating channel ${APP_CHANNEL} with ${APP_CHANNEL_TX}..."
2019-05-02 17:30:13 +08:00
channelCreate ${APP_CHANNEL} ${APP_CHANNEL_TX} ${ORDERER0_URL}
2017-09-01 20:09:18 +08:00
2017-09-14 15:26:06 +08:00
sleep 1
2017-09-01 20:09:18 +08:00
## Join all the peers to the channel
2017-09-11 10:33:29 +08:00
echo_b "Having peer0 join the channel..."
2017-12-06 16:24:33 +08:00
channelJoin ${APP_CHANNEL} 0
2017-09-14 15:26:06 +08:00
2017-09-01 20:09:18 +08:00
## Set the anchor peers for each org in the channel
2017-10-28 14:41:13 +08:00
echo_b "Updating anchor peers for peer0/org1... no use for only single channel"
2021-03-04 06:06:06 +08:00
channelUpdate ${APP_CHANNEL} 1 0 ${ORDERER0_URL} ${ORDERER0_TLS_ROOTCERT} Org1MSPanchors.tx
2017-09-14 15:26:06 +08:00
2017-09-01 20:09:18 +08:00
## Install chaincode on all peers
2018-01-05 14:37:52 +08:00
CC_NAME=${CC_02_NAME}
CC_PATH=${CC_02_PATH}
echo_b "Installing chaincode ${CC_NAME} on peer0..."
chaincodeInstall 1 0 ${CC_NAME} ${CC_INIT_VERSION} ${CC_PATH}
2017-09-14 15:26:06 +08:00
2017-09-01 20:09:18 +08:00
# Instantiate chaincode on all peers
# Instantiate can only be executed once on any node
echo_b "Instantiating chaincode on the channel..."
2017-12-06 16:24:33 +08:00
chaincodeInstantiate ${APP_CHANNEL} 0
2017-09-14 15:26:06 +08:00
2017-12-06 16:24:33 +08:00
echo_g "=============== All GOOD, network initialization done =============== "
2017-09-01 20:09:18 +08:00
echo
exit 0