Skip to content

Commit

Permalink
first-network/scripts/*: Make Chaincode name configurable (#118)
Browse files Browse the repository at this point in the history
Signed-off-by: Anoop Vijayan Maniankara <anoop@tuxera.com>
  • Loading branch information
Anoop Vijayan Maniankara authored Feb 23, 2020
1 parent e204ebb commit 9ef61e2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
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

This comment has been minimized.

Copy link
@wzt0921

wzt0921 Feb 26, 2020

Because of this statement, I cannot execute byfn.sh successfully

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

0 comments on commit 9ef61e2

Please sign in to comment.