Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first-network/scripts/*: Make Chaincode name configurable #118

Merged
merged 1 commit into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions first-network/scripts/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ CC_SRC_LANGUAGE="$3"
TIMEOUT="$4"
VERBOSE="$5"
NO_CHAINCODE="$6"
NAME="$7"
: ${CHANNEL_NAME:="mychannel"}
: ${DELAY:="3"}
: ${CC_SRC_LANGUAGE:="go"}
: ${TIMEOUT:="10"}
: ${VERBOSE:="false"}
: ${NO_CHAINCODE:="false"}
: ${NAME:="mycc"}
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
COUNTER=1
MAX_RETRY=20
Expand All @@ -43,6 +45,7 @@ fi


echo "Channel name : "$CHANNEL_NAME
echo "Chaincode name : "$NAME

# import utils
. scripts/utils.sh
Expand Down
2 changes: 2 additions & 0 deletions first-network/scripts/step1org3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ DELAY="$2"
CC_SRC_LANGUAGE="$3"
TIMEOUT="$4"
VERBOSE="$5"
NAME="$6"
: ${CHANNEL_NAME:="mychannel"}
: ${DELAY:="3"}
: ${CC_SRC_LANGUAGE:="go"}
: ${TIMEOUT:="10"}
: ${VERBOSE:="false"}
: ${NAME:="mycc"}
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
COUNTER=1
MAX_RETRY=5
Expand Down
2 changes: 2 additions & 0 deletions first-network/scripts/step2org3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ DELAY="$2"
CC_SRC_LANGUAGE="$3"
TIMEOUT="$4"
VERBOSE="$5"
NAME="$6"
: ${CHANNEL_NAME:="mychannel"}
: ${DELAY:="3"}
: ${CC_SRC_LANGUAGE:="go"}
: ${TIMEOUT:="10"}
: ${VERBOSE:="false"}
: ${NAME:="mycc"}
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
COUNTER=1
MAX_RETRY=5
Expand Down
2 changes: 2 additions & 0 deletions first-network/scripts/testorg3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ DELAY="$2"
CC_SRC_LANGUAGE="$3"
TIMEOUT="$4"
VERBOSE="$5"
NAME="$6"
: ${CHANNEL_NAME:="mychannel"}
: ${TIMEOUT:="10"}
: ${CC_SRC_LANGUAGE:="go"}
: ${VERBOSE:="false"}
: ${NAME:="mycc"}
CC_SRC_LANGUAGE=`echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]`
COUNTER=1
MAX_RETRY=5
Expand Down
2 changes: 2 additions & 0 deletions first-network/scripts/upgrade_to_v14.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ DELAY="$2"
CC_SRC_LANGUAGE="$3"
TIMEOUT="$4"
VERBOSE="$5"
NAME="$6"
: ${CHANNEL_NAME:="mychannel"}
: ${DELAY:="5"}
: ${CC_SRC_LANGUAGE:="go"}
: ${TIMEOUT:="10"}
: ${VERBOSE:="false"}
: ${NAME:="mycc"}
CC_SRC_LANGUAGE=$(echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:])
COUNTER=1
MAX_RETRY=5
Expand Down
23 changes: 12 additions & 11 deletions first-network/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ packageChaincode() {
ORG=$3
setGlobals $PEER $ORG
set -x
peer lifecycle chaincode package mycc.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label mycc_${VERSION} >&log.txt
peer lifecycle chaincode package $NAME.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label $NAME_${VERSION} >&log.txt
res=$?
set +x
cat log.txt
Expand All @@ -133,9 +133,10 @@ packageChaincode() {
installChaincode() {
PEER=$1
ORG=$2
NAME=$3
setGlobals $PEER $ORG
set -x
peer lifecycle chaincode install mycc.tar.gz >&log.txt
peer lifecycle chaincode install $NAME.tar.gz >&log.txt
res=$?
set +x
cat log.txt
Expand Down Expand Up @@ -170,11 +171,11 @@ approveForMyOrg() {

if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
set -x
peer lifecycle chaincode approveformyorg --channelID $CHANNEL_NAME --name mycc --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
peer lifecycle chaincode approveformyorg --channelID $CHANNEL_NAME --name $NAME --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
set +x
else
set -x
peer lifecycle chaincode approveformyorg --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name mycc --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
peer lifecycle chaincode approveformyorg --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name $NAME --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${VERSION} --waitForEvent >&log.txt
set +x
fi
cat log.txt
Expand All @@ -196,12 +197,12 @@ commitChaincodeDefinition() {
# it using the "-o" option
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
set -x
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID $CHANNEL_NAME --name $NAME $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
res=$?
set +x
else
set -x
peer lifecycle chaincode commit -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
peer lifecycle chaincode commit -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name $NAME $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --init-required >&log.txt
res=$?
set +x
fi
Expand Down Expand Up @@ -230,7 +231,7 @@ checkCommitReadiness() {
sleep $DELAY
echo "Attempting to check the commit readiness of the chaincode definition on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
set -x
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name mycc $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name $NAME $PEER_CONN_PARMS --version ${VERSION} --sequence ${VERSION} --output json --init-required >&log.txt
res=$?
set +x
test $res -eq 0 || continue
Expand Down Expand Up @@ -271,7 +272,7 @@ queryCommitted() {
sleep $DELAY
echo "Attempting to Query committed status on peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
set -x
peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name mycc >&log.txt
peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name $NAME >&log.txt
res=$?
set +x
test $res -eq 0 && VALUE=$(cat log.txt | grep -o '^Version: [0-9], Sequence: [0-9], Endorsement Plugin: escc, Validation Plugin: vscc')
Expand Down Expand Up @@ -306,7 +307,7 @@ chaincodeQuery() {
sleep $DELAY
echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
set -x
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt
peer chaincode query -C $CHANNEL_NAME -n $NAME -c '{"Args":["query","a"]}' >&log.txt
res=$?
set +x
test $res -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}')
Expand Down Expand Up @@ -435,12 +436,12 @@ chaincodeInvoke() {
# it using the "-o" option
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
set -x
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc $PEER_CONN_PARMS ${INIT_ARG} -c ${CCARGS} >&log.txt
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n $NAME $PEER_CONN_PARMS ${INIT_ARG} -c ${CCARGS} >&log.txt
res=$?
set +x
else
set -x
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc $PEER_CONN_PARMS ${INIT_ARG} -c ${CCARGS} >&log.txt
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n $NAME $PEER_CONN_PARMS ${INIT_ARG} -c ${CCARGS} >&log.txt
res=$?
set +x
fi
Expand Down