mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 17:45:10 +00:00
FAB-10801 format and styling for shell artifacts
formatting for existing shell scripts Change-Id: I7e067730558bc55edc74b73e59195af7c825d8b2 Signed-off-by: Naga Pemmara <naga.pemmaraju@ibm.com>
This commit is contained in:
parent
e95210e9bc
commit
20ad472356
2 changed files with 277 additions and 268 deletions
|
|
@ -33,7 +33,7 @@ export FABRIC_CFG_PATH=${PWD}
|
||||||
export VERBOSE=false
|
export VERBOSE=false
|
||||||
|
|
||||||
# Print the usage message
|
# Print the usage message
|
||||||
function printHelp () {
|
function printHelp() {
|
||||||
echo "Usage: "
|
echo "Usage: "
|
||||||
echo " byfn.sh <mode> [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>] [-l <language>] [-i <imagetag>] [-v]"
|
echo " byfn.sh <mode> [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>] [-l <language>] [-i <imagetag>] [-v]"
|
||||||
echo " <mode> - one of 'up', 'down', 'restart', 'generate' or 'upgrade'"
|
echo " <mode> - one of 'up', 'down', 'restart', 'generate' or 'upgrade'"
|
||||||
|
|
@ -69,27 +69,27 @@ function printHelp () {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ask user for confirmation to proceed
|
# Ask user for confirmation to proceed
|
||||||
function askProceed () {
|
function askProceed() {
|
||||||
read -p "Continue? [Y/n] " ans
|
read -p "Continue? [Y/n] " ans
|
||||||
case "$ans" in
|
case "$ans" in
|
||||||
y|Y|"" )
|
y | Y | "")
|
||||||
echo "proceeding ..."
|
echo "proceeding ..."
|
||||||
;;
|
;;
|
||||||
n|N )
|
n | N)
|
||||||
echo "exiting..."
|
echo "exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
* )
|
*)
|
||||||
echo "invalid response"
|
echo "invalid response"
|
||||||
askProceed
|
askProceed
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Obtain CONTAINER_IDS and remove them
|
# Obtain CONTAINER_IDS and remove them
|
||||||
# TODO Might want to make this optional - could clear other containers
|
# TODO Might want to make this optional - could clear other containers
|
||||||
function clearContainers () {
|
function clearContainers() {
|
||||||
CONTAINER_IDS=$(docker ps -a |awk '($2 ~ /dev-peer.*.mycc.*/) {print $1}')
|
CONTAINER_IDS=$(docker ps -a | awk '($2 ~ /dev-peer.*.mycc.*/) {print $1}')
|
||||||
if [ -z "$CONTAINER_IDS" -o "$CONTAINER_IDS" == " " ]; then
|
if [ -z "$CONTAINER_IDS" -o "$CONTAINER_IDS" == " " ]; then
|
||||||
echo "---- No containers available for deletion ----"
|
echo "---- No containers available for deletion ----"
|
||||||
else
|
else
|
||||||
|
|
@ -101,7 +101,7 @@ function clearContainers () {
|
||||||
# specifically the following images are often left behind:
|
# specifically the following images are often left behind:
|
||||||
# TODO list generated image naming patterns
|
# TODO list generated image naming patterns
|
||||||
function removeUnwantedImages() {
|
function removeUnwantedImages() {
|
||||||
DOCKER_IMAGE_IDS=$(docker images|awk '($1 ~ /dev-peer.*.mycc.*/) {print $3}')
|
DOCKER_IMAGE_IDS=$(docker images | awk '($1 ~ /dev-peer.*.mycc.*/) {print $3}')
|
||||||
if [ -z "$DOCKER_IMAGE_IDS" -o "$DOCKER_IMAGE_IDS" == " " ]; then
|
if [ -z "$DOCKER_IMAGE_IDS" -o "$DOCKER_IMAGE_IDS" == " " ]; then
|
||||||
echo "---- No images available for deletion ----"
|
echo "---- No images available for deletion ----"
|
||||||
else
|
else
|
||||||
|
|
@ -119,35 +119,35 @@ function checkPrereqs() {
|
||||||
# Note, we check configtxlator externally because it does not require a config file, and peer in the
|
# Note, we check configtxlator externally because it does not require a config file, and peer in the
|
||||||
# docker image because of FAB-8551 that makes configtxlator return 'development version' in docker
|
# docker image because of FAB-8551 that makes configtxlator return 'development version' in docker
|
||||||
LOCAL_VERSION=$(configtxlator version | sed -ne 's/ Version: //p')
|
LOCAL_VERSION=$(configtxlator version | sed -ne 's/ Version: //p')
|
||||||
DOCKER_IMAGE_VERSION=$(docker run --rm hyperledger/fabric-tools:$IMAGETAG peer version | sed -ne 's/ Version: //p'|head -1)
|
DOCKER_IMAGE_VERSION=$(docker run --rm hyperledger/fabric-tools:$IMAGETAG peer version | sed -ne 's/ Version: //p' | head -1)
|
||||||
|
|
||||||
echo "LOCAL_VERSION=$LOCAL_VERSION"
|
echo "LOCAL_VERSION=$LOCAL_VERSION"
|
||||||
echo "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION"
|
echo "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION"
|
||||||
|
|
||||||
if [ "$LOCAL_VERSION" != "$DOCKER_IMAGE_VERSION" ] ; then
|
if [ "$LOCAL_VERSION" != "$DOCKER_IMAGE_VERSION" ]; then
|
||||||
echo "=================== WARNING ==================="
|
echo "=================== WARNING ==================="
|
||||||
echo " Local fabric binaries and docker images are "
|
echo " Local fabric binaries and docker images are "
|
||||||
echo " out of sync. This may cause problems. "
|
echo " out of sync. This may cause problems. "
|
||||||
echo "==============================================="
|
echo "==============================================="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for UNSUPPORTED_VERSION in $BLACKLISTED_VERSIONS ; do
|
for UNSUPPORTED_VERSION in $BLACKLISTED_VERSIONS; do
|
||||||
echo "$LOCAL_VERSION" | grep -q $UNSUPPORTED_VERSION
|
echo "$LOCAL_VERSION" | grep -q $UNSUPPORTED_VERSION
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "ERROR! Local Fabric binary version of $LOCAL_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples."
|
echo "ERROR! Local Fabric binary version of $LOCAL_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$DOCKER_IMAGE_VERSION" | grep -q $UNSUPPORTED_VERSION
|
echo "$DOCKER_IMAGE_VERSION" | grep -q $UNSUPPORTED_VERSION
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "ERROR! Fabric Docker image version of $DOCKER_IMAGE_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples."
|
echo "ERROR! Fabric Docker image version of $DOCKER_IMAGE_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate the needed certificates, the genesis block and start the network.
|
# Generate the needed certificates, the genesis block and start the network.
|
||||||
function networkUp () {
|
function networkUp() {
|
||||||
checkPrereqs
|
checkPrereqs
|
||||||
# generate artifacts if they don't exist
|
# generate artifacts if they don't exist
|
||||||
if [ ! -d "crypto-config" ]; then
|
if [ ! -d "crypto-config" ]; then
|
||||||
|
|
@ -175,8 +175,8 @@ function networkUp () {
|
||||||
# Upgrade the network from v1.0.x to v1.1
|
# Upgrade the network from v1.0.x to v1.1
|
||||||
# Stop the orderer and peers, backup the ledger from orderer and peers, cleanup chaincode containers and images
|
# Stop the orderer and peers, backup the ledger from orderer and peers, cleanup chaincode containers and images
|
||||||
# and relaunch the orderer and peers with latest tag
|
# and relaunch the orderer and peers with latest tag
|
||||||
function upgradeNetwork () {
|
function upgradeNetwork() {
|
||||||
docker inspect -f '{{.Config.Volumes}}' orderer.example.com |grep -q '/var/hyperledger/production/orderer'
|
docker inspect -f '{{.Config.Volumes}}' orderer.example.com | grep -q '/var/hyperledger/production/orderer'
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR !!!! This network does not appear to be using volumes for its ledgers, did you start from fabric-samples >= v1.0.6?"
|
echo "ERROR !!!! This network does not appear to be using volumes for its ledgers, did you start from fabric-samples >= v1.0.6?"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -189,9 +189,9 @@ function upgradeNetwork () {
|
||||||
|
|
||||||
export IMAGE_TAG=$IMAGETAG
|
export IMAGE_TAG=$IMAGETAG
|
||||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||||
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH"
|
COMPOSE_FILES="-f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH"
|
||||||
else
|
else
|
||||||
COMPOSE_FILES="-f $COMPOSE_FILE"
|
COMPOSE_FILES="-f $COMPOSE_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# removing the cli container
|
# removing the cli container
|
||||||
|
|
@ -212,12 +212,12 @@ function upgradeNetwork () {
|
||||||
|
|
||||||
# Remove any old containers and images for this peer
|
# Remove any old containers and images for this peer
|
||||||
CC_CONTAINERS=$(docker ps | grep dev-$PEER | awk '{print $1}')
|
CC_CONTAINERS=$(docker ps | grep dev-$PEER | awk '{print $1}')
|
||||||
if [ -n "$CC_CONTAINERS" ] ; then
|
if [ -n "$CC_CONTAINERS" ]; then
|
||||||
docker rm -f $CC_CONTAINERS
|
docker rm -f $CC_CONTAINERS
|
||||||
fi
|
fi
|
||||||
CC_IMAGES=$(docker images | grep dev-$PEER | awk '{print $1}')
|
CC_IMAGES=$(docker images | grep dev-$PEER | awk '{print $1}')
|
||||||
if [ -n "$CC_IMAGES" ] ; then
|
if [ -n "$CC_IMAGES" ]; then
|
||||||
docker rmi -f $CC_IMAGES
|
docker rmi -f $CC_IMAGES
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start the peer again
|
# Start the peer again
|
||||||
|
|
@ -231,9 +231,8 @@ function upgradeNetwork () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Tear down running network
|
# Tear down running network
|
||||||
function networkDown () {
|
function networkDown() {
|
||||||
# stop org3 containers also in addition to org1 and org2, in case we were running sample to add org3
|
# stop org3 containers also in addition to org1 and org2, in case we were running sample to add org3
|
||||||
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH -f $COMPOSE_FILE_ORG3 down --volumes --remove-orphans
|
docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH -f $COMPOSE_FILE_ORG3 down --volumes --remove-orphans
|
||||||
|
|
||||||
|
|
@ -256,10 +255,10 @@ function networkDown () {
|
||||||
# Using docker-compose-e2e-template.yaml, replace constants with private key file names
|
# Using docker-compose-e2e-template.yaml, replace constants with private key file names
|
||||||
# generated by the cryptogen tool and output a docker-compose.yaml specific to this
|
# generated by the cryptogen tool and output a docker-compose.yaml specific to this
|
||||||
# configuration
|
# configuration
|
||||||
function replacePrivateKey () {
|
function replacePrivateKey() {
|
||||||
# sed on MacOSX does not support -i flag with a null extension. We will use
|
# sed on MacOSX does not support -i flag with a null extension. We will use
|
||||||
# 't' for our back-up's extension and delete it at the end of the function
|
# 't' for our back-up's extension and delete it at the end of the function
|
||||||
ARCH=`uname -s | grep Darwin`
|
ARCH=$(uname -s | grep Darwin)
|
||||||
if [ "$ARCH" == "Darwin" ]; then
|
if [ "$ARCH" == "Darwin" ]; then
|
||||||
OPTS="-it"
|
OPTS="-it"
|
||||||
else
|
else
|
||||||
|
|
@ -304,7 +303,7 @@ function replacePrivateKey () {
|
||||||
# After we run the tool, the certs will be parked in a folder titled ``crypto-config``.
|
# After we run the tool, the certs will be parked in a folder titled ``crypto-config``.
|
||||||
|
|
||||||
# Generates Org certs using cryptogen tool
|
# Generates Org certs using cryptogen tool
|
||||||
function generateCerts (){
|
function generateCerts() {
|
||||||
which cryptogen
|
which cryptogen
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "cryptogen tool not found. exiting"
|
echo "cryptogen tool not found. exiting"
|
||||||
|
|
@ -419,7 +418,7 @@ function generateChannelArtifacts() {
|
||||||
echo "#################################################################"
|
echo "#################################################################"
|
||||||
set -x
|
set -x
|
||||||
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \
|
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \
|
||||||
./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
|
./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
if [ $res -ne 0 ]; then
|
if [ $res -ne 0 ]; then
|
||||||
|
|
@ -431,7 +430,7 @@ function generateChannelArtifacts() {
|
||||||
|
|
||||||
# Obtain the OS and Architecture string that will be used to select the correct
|
# Obtain the OS and Architecture string that will be used to select the correct
|
||||||
# native binaries for your platform
|
# native binaries for your platform
|
||||||
OS_ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}')
|
OS_ARCH=$(echo "$(uname -s | tr '[:upper:]' '[:lower:]' | sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}')
|
||||||
# timeout duration - the duration the CLI should wait for a response from
|
# timeout duration - the duration the CLI should wait for a response from
|
||||||
# another container before giving up
|
# another container before giving up
|
||||||
CLI_TIMEOUT=10
|
CLI_TIMEOUT=10
|
||||||
|
|
@ -451,10 +450,11 @@ LANGUAGE=golang
|
||||||
# default image tag
|
# default image tag
|
||||||
IMAGETAG="latest"
|
IMAGETAG="latest"
|
||||||
# Parse commandline args
|
# Parse commandline args
|
||||||
if [ "$1" = "-m" ];then # supports old usage, muscle memory is powerful!
|
if [ "$1" = "-m" ]; then # supports old usage, muscle memory is powerful!
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
MODE=$1;shift
|
MODE=$1
|
||||||
|
shift
|
||||||
# Determine whether starting, stopping, restarting, generating or upgrading
|
# Determine whether starting, stopping, restarting, generating or upgrading
|
||||||
if [ "$MODE" == "up" ]; then
|
if [ "$MODE" == "up" ]; then
|
||||||
EXPMODE="Starting"
|
EXPMODE="Starting"
|
||||||
|
|
@ -473,37 +473,45 @@ fi
|
||||||
|
|
||||||
while getopts "h?c:t:d:f:s:l:i:v" opt; do
|
while getopts "h?c:t:d:f:s:l:i:v" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
h|\?)
|
h | \?)
|
||||||
printHelp
|
printHelp
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
c) CHANNEL_NAME=$OPTARG
|
c)
|
||||||
|
CHANNEL_NAME=$OPTARG
|
||||||
;;
|
;;
|
||||||
t) CLI_TIMEOUT=$OPTARG
|
t)
|
||||||
|
CLI_TIMEOUT=$OPTARG
|
||||||
;;
|
;;
|
||||||
d) CLI_DELAY=$OPTARG
|
d)
|
||||||
|
CLI_DELAY=$OPTARG
|
||||||
;;
|
;;
|
||||||
f) COMPOSE_FILE=$OPTARG
|
f)
|
||||||
|
COMPOSE_FILE=$OPTARG
|
||||||
;;
|
;;
|
||||||
s) IF_COUCHDB=$OPTARG
|
s)
|
||||||
|
IF_COUCHDB=$OPTARG
|
||||||
;;
|
;;
|
||||||
l) LANGUAGE=$OPTARG
|
l)
|
||||||
|
LANGUAGE=$OPTARG
|
||||||
;;
|
;;
|
||||||
i) IMAGETAG=`uname -m`"-"$OPTARG
|
i)
|
||||||
|
IMAGETAG=$(uname -m)"-"$OPTARG
|
||||||
;;
|
;;
|
||||||
v) VERBOSE=true
|
v)
|
||||||
|
VERBOSE=true
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Announce what was requested
|
# Announce what was requested
|
||||||
|
|
||||||
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
if [ "${IF_COUCHDB}" == "couchdb" ]; then
|
||||||
echo
|
echo
|
||||||
echo "${EXPMODE} with channel '${CHANNEL_NAME}' and CLI timeout of '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${IF_COUCHDB}'"
|
echo "${EXPMODE} with channel '${CHANNEL_NAME}' and CLI timeout of '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${IF_COUCHDB}'"
|
||||||
else
|
else
|
||||||
echo "${EXPMODE} with channel '${CHANNEL_NAME}' and CLI timeout of '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds"
|
echo "${EXPMODE} with channel '${CHANNEL_NAME}' and CLI timeout of '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds"
|
||||||
fi
|
fi
|
||||||
# ask for confirmation to proceed
|
# ask for confirmation to proceed
|
||||||
askProceed
|
askProceed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,165 +12,164 @@ PEER0_ORG2_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrga
|
||||||
PEER0_ORG3_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
|
PEER0_ORG3_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
|
||||||
|
|
||||||
# verify the result of the end-to-end test
|
# verify the result of the end-to-end test
|
||||||
verifyResult () {
|
verifyResult() {
|
||||||
if [ $1 -ne 0 ] ; then
|
if [ $1 -ne 0 ]; then
|
||||||
echo "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!"
|
echo "!!!!!!!!!!!!!!! "$2" !!!!!!!!!!!!!!!!"
|
||||||
echo "========= ERROR !!! FAILED to execute End-2-End Scenario ==========="
|
echo "========= ERROR !!! FAILED to execute End-2-End Scenario ==========="
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set OrdererOrg.Admin globals
|
# Set OrdererOrg.Admin globals
|
||||||
setOrdererGlobals() {
|
setOrdererGlobals() {
|
||||||
CORE_PEER_LOCALMSPID="OrdererMSP"
|
CORE_PEER_LOCALMSPID="OrdererMSP"
|
||||||
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
||||||
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp
|
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp
|
||||||
}
|
}
|
||||||
|
|
||||||
setGlobals () {
|
setGlobals() {
|
||||||
PEER=$1
|
PEER=$1
|
||||||
ORG=$2
|
ORG=$2
|
||||||
if [ $ORG -eq 1 ] ; then
|
if [ $ORG -eq 1 ]; then
|
||||||
CORE_PEER_LOCALMSPID="Org1MSP"
|
CORE_PEER_LOCALMSPID="Org1MSP"
|
||||||
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG1_CA
|
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG1_CA
|
||||||
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
|
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
|
||||||
if [ $PEER -eq 0 ]; then
|
if [ $PEER -eq 0 ]; then
|
||||||
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
|
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
|
||||||
else
|
else
|
||||||
CORE_PEER_ADDRESS=peer1.org1.example.com:7051
|
CORE_PEER_ADDRESS=peer1.org1.example.com:7051
|
||||||
fi
|
fi
|
||||||
elif [ $ORG -eq 2 ] ; then
|
elif [ $ORG -eq 2 ]; then
|
||||||
CORE_PEER_LOCALMSPID="Org2MSP"
|
CORE_PEER_LOCALMSPID="Org2MSP"
|
||||||
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG2_CA
|
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG2_CA
|
||||||
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
|
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
|
||||||
if [ $PEER -eq 0 ]; then
|
if [ $PEER -eq 0 ]; then
|
||||||
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
|
CORE_PEER_ADDRESS=peer0.org2.example.com:7051
|
||||||
else
|
else
|
||||||
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
|
CORE_PEER_ADDRESS=peer1.org2.example.com:7051
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [ $ORG -eq 3 ] ; then
|
elif [ $ORG -eq 3 ]; then
|
||||||
CORE_PEER_LOCALMSPID="Org3MSP"
|
CORE_PEER_LOCALMSPID="Org3MSP"
|
||||||
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG3_CA
|
CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG3_CA
|
||||||
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
|
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp
|
||||||
if [ $PEER -eq 0 ]; then
|
if [ $PEER -eq 0 ]; then
|
||||||
CORE_PEER_ADDRESS=peer0.org3.example.com:7051
|
CORE_PEER_ADDRESS=peer0.org3.example.com:7051
|
||||||
else
|
else
|
||||||
CORE_PEER_ADDRESS=peer1.org3.example.com:7051
|
CORE_PEER_ADDRESS=peer1.org3.example.com:7051
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "================== ERROR !!! ORG Unknown =================="
|
echo "================== ERROR !!! ORG Unknown =================="
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$VERBOSE" == "true" ]; then
|
if [ "$VERBOSE" == "true" ]; then
|
||||||
env |grep CORE
|
env | grep CORE
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updateAnchorPeers() {
|
updateAnchorPeers() {
|
||||||
PEER=$1
|
PEER=$1
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
|
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
||||||
set -x
|
set -x
|
||||||
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt
|
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
else
|
else
|
||||||
set -x
|
set -x
|
||||||
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
|
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
fi
|
fi
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Anchor peer update failed"
|
verifyResult $res "Anchor peer update failed"
|
||||||
echo "===================== Anchor peers updated for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME' ===================== "
|
echo "===================== Anchor peers updated for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME' ===================== "
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
## Sometimes Join takes time hence RETRY at least 5 times
|
## Sometimes Join takes time hence RETRY at least 5 times
|
||||||
joinChannelWithRetry () {
|
joinChannelWithRetry() {
|
||||||
PEER=$1
|
PEER=$1
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
peer channel join -b $CHANNEL_NAME.block >&log.txt
|
peer channel join -b $CHANNEL_NAME.block >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
cat log.txt
|
cat log.txt
|
||||||
if [ $res -ne 0 -a $COUNTER -lt $MAX_RETRY ]; then
|
if [ $res -ne 0 -a $COUNTER -lt $MAX_RETRY ]; then
|
||||||
COUNTER=` expr $COUNTER + 1`
|
COUNTER=$(expr $COUNTER + 1)
|
||||||
echo "peer${PEER}.org${ORG} failed to join the channel, Retry after $DELAY seconds"
|
echo "peer${PEER}.org${ORG} failed to join the channel, Retry after $DELAY seconds"
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
joinChannelWithRetry $PEER $ORG
|
joinChannelWithRetry $PEER $ORG
|
||||||
else
|
else
|
||||||
COUNTER=1
|
COUNTER=1
|
||||||
fi
|
fi
|
||||||
verifyResult $res "After $MAX_RETRY attempts, peer${PEER}.org${ORG} has failed to join channel '$CHANNEL_NAME' "
|
verifyResult $res "After $MAX_RETRY attempts, peer${PEER}.org${ORG} has failed to join channel '$CHANNEL_NAME' "
|
||||||
}
|
}
|
||||||
|
|
||||||
installChaincode () {
|
installChaincode() {
|
||||||
PEER=$1
|
PEER=$1
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
VERSION=${3:-1.0}
|
VERSION=${3:-1.0}
|
||||||
set -x
|
set -x
|
||||||
peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt
|
peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has failed"
|
verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has failed"
|
||||||
echo "===================== Chaincode is installed on peer${PEER}.org${ORG} ===================== "
|
echo "===================== Chaincode is installed on peer${PEER}.org${ORG} ===================== "
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
instantiateChaincode () {
|
instantiateChaincode() {
|
||||||
PEER=$1
|
PEER=$1
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
VERSION=${3:-1.0}
|
VERSION=${3:-1.0}
|
||||||
|
|
||||||
# while 'peer chaincode' command can get the orderer endpoint from the peer
|
|
||||||
# (if join was successful), let's supply it directly as we know it using
|
|
||||||
# the "-o" option
|
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
|
||||||
set -x
|
|
||||||
peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
|
|
||||||
res=$?
|
|
||||||
set +x
|
|
||||||
else
|
|
||||||
set -x
|
|
||||||
peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
|
|
||||||
res=$?
|
|
||||||
set +x
|
|
||||||
fi
|
|
||||||
cat log.txt
|
|
||||||
verifyResult $res "Chaincode instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed"
|
|
||||||
echo "===================== Chaincode is instantiated on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
upgradeChaincode () {
|
|
||||||
PEER=$1
|
|
||||||
ORG=$2
|
|
||||||
setGlobals $PEER $ORG
|
|
||||||
|
|
||||||
|
# while 'peer chaincode' command can get the orderer endpoint from the peer
|
||||||
|
# (if join was successful), let's supply it directly as we know it using
|
||||||
|
# the "-o" option
|
||||||
|
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
||||||
set -x
|
set -x
|
||||||
peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')"
|
peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
cat log.txt
|
else
|
||||||
verifyResult $res "Chaincode upgrade on peer${PEER}.org${ORG} has failed"
|
set -x
|
||||||
echo "===================== Chaincode is upgraded on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer')" >&log.txt
|
||||||
echo
|
res=$?
|
||||||
|
set +x
|
||||||
|
fi
|
||||||
|
cat log.txt
|
||||||
|
verifyResult $res "Chaincode instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed"
|
||||||
|
echo "===================== Chaincode is instantiated on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
chaincodeQuery () {
|
upgradeChaincode() {
|
||||||
|
PEER=$1
|
||||||
|
ORG=$2
|
||||||
|
setGlobals $PEER $ORG
|
||||||
|
|
||||||
|
set -x
|
||||||
|
peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "AND ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')"
|
||||||
|
res=$?
|
||||||
|
set +x
|
||||||
|
cat log.txt
|
||||||
|
verifyResult $res "Chaincode upgrade on peer${PEER}.org${ORG} has failed"
|
||||||
|
echo "===================== Chaincode is upgraded on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
chaincodeQuery() {
|
||||||
PEER=$1
|
PEER=$1
|
||||||
ORG=$2
|
ORG=$2
|
||||||
setGlobals $PEER $ORG
|
setGlobals $PEER $ORG
|
||||||
|
|
@ -181,31 +180,32 @@ chaincodeQuery () {
|
||||||
|
|
||||||
# continue to poll
|
# continue to poll
|
||||||
# we either get a successful response, or reach TIMEOUT
|
# we either get a successful response, or reach TIMEOUT
|
||||||
while test "$(($(date +%s)-starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
while
|
||||||
|
test "$(($(date +%s) - starttime))" -lt "$TIMEOUT" -a $rc -ne 0
|
||||||
do
|
do
|
||||||
sleep $DELAY
|
sleep $DELAY
|
||||||
echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s)-starttime)) secs"
|
echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s) - starttime)) secs"
|
||||||
set -x
|
set -x
|
||||||
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt
|
peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
test $res -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}')
|
test $res -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}')
|
||||||
test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
|
test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
|
||||||
# removed the string "Query Result" from peer chaincode query command
|
# removed the string "Query Result" from peer chaincode query command
|
||||||
# result. as a result, have to support both options until the change
|
# result. as a result, have to support both options until the change
|
||||||
# is merged.
|
# is merged.
|
||||||
test $rc -ne 0 && VALUE=$(cat log.txt | egrep '^[0-9]+$')
|
test $rc -ne 0 && VALUE=$(cat log.txt | egrep '^[0-9]+$')
|
||||||
test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
|
test "$VALUE" = "$EXPECTED_RESULT" && let rc=0
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
cat log.txt
|
cat log.txt
|
||||||
if test $rc -eq 0 ; then
|
if test $rc -eq 0; then
|
||||||
echo "===================== Query successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
echo "===================== Query successful on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' ===================== "
|
||||||
else
|
else
|
||||||
echo "!!!!!!!!!!!!!!! Query result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
|
echo "!!!!!!!!!!!!!!! Query result on peer${PEER}.org${ORG} is INVALID !!!!!!!!!!!!!!!!"
|
||||||
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
|
echo "================== ERROR !!! FAILED to execute End-2-End Scenario =================="
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,19 +230,19 @@ fetchChannelConfig() {
|
||||||
|
|
||||||
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
echo "Decoding config block to JSON and isolating config to ${OUTPUT}"
|
||||||
set -x
|
set -x
|
||||||
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config > "${OUTPUT}"
|
configtxlator proto_decode --input config_block.pb --type common.Block | jq .data.data[0].payload.data.config >"${OUTPUT}"
|
||||||
set +x
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
# signConfigtxAsPeerOrg <org> <configtx.pb>
|
# signConfigtxAsPeerOrg <org> <configtx.pb>
|
||||||
# Set the peerOrg admin of an org and signing the config update
|
# Set the peerOrg admin of an org and signing the config update
|
||||||
signConfigtxAsPeerOrg() {
|
signConfigtxAsPeerOrg() {
|
||||||
PEERORG=$1
|
PEERORG=$1
|
||||||
TX=$2
|
TX=$2
|
||||||
setGlobals 0 $PEERORG
|
setGlobals 0 $PEERORG
|
||||||
set -x
|
set -x
|
||||||
peer channel signconfigtx -f "${TX}"
|
peer channel signconfigtx -f "${TX}"
|
||||||
set +x
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
# createConfigUpdate <channel_id> <original_config.json> <modified_config.json> <output.pb>
|
# createConfigUpdate <channel_id> <original_config.json> <modified_config.json> <output.pb>
|
||||||
|
|
@ -255,65 +255,66 @@ createConfigUpdate() {
|
||||||
OUTPUT=$4
|
OUTPUT=$4
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
configtxlator proto_encode --input "${ORIGINAL}" --type common.Config > original_config.pb
|
configtxlator proto_encode --input "${ORIGINAL}" --type common.Config >original_config.pb
|
||||||
configtxlator proto_encode --input "${MODIFIED}" --type common.Config > modified_config.pb
|
configtxlator proto_encode --input "${MODIFIED}" --type common.Config >modified_config.pb
|
||||||
configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb > config_update.pb
|
configtxlator compute_update --channel_id "${CHANNEL}" --original original_config.pb --updated modified_config.pb >config_update.pb
|
||||||
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate > config_update.json
|
configtxlator proto_decode --input config_update.pb --type common.ConfigUpdate >config_update.json
|
||||||
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . > config_update_in_envelope.json
|
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' | jq . >config_update_in_envelope.json
|
||||||
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope > "${OUTPUT}"
|
configtxlator proto_encode --input config_update_in_envelope.json --type common.Envelope >"${OUTPUT}"
|
||||||
set +x
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
# parsePeerConnectionParameters $@
|
# parsePeerConnectionParameters $@
|
||||||
# Helper function that takes the parameters from a chaincode operation
|
# Helper function that takes the parameters from a chaincode operation
|
||||||
# (e.g. invoke, query, instantiate) and checks for an even number of
|
# (e.g. invoke, query, instantiate) and checks for an even number of
|
||||||
# peers and associated org, then sets $PEER_CONN_PARMS and $PEERS
|
# peers and associated org, then sets $PEER_CONN_PARMS and $PEERS
|
||||||
parsePeerConnectionParameters() {
|
parsePeerConnectionParameters() {
|
||||||
# check for uneven number of peer and org parameters
|
# check for uneven number of peer and org parameters
|
||||||
if [ $(( $# % 2 )) -ne 0 ]; then
|
if [ $(($# % 2)) -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PEER_CONN_PARMS=""
|
PEER_CONN_PARMS=""
|
||||||
PEERS=""
|
PEERS=""
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
PEER="peer$1.org$2"
|
PEER="peer$1.org$2"
|
||||||
PEERS="$PEERS $PEER"
|
PEERS="$PEERS $PEER"
|
||||||
PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $PEER.example.com:7051"
|
PEER_CONN_PARMS="$PEER_CONN_PARMS --peerAddresses $PEER.example.com:7051"
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "true" ]; then
|
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "true" ]; then
|
||||||
TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER$1_ORG$2_CA")
|
TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER$1_ORG$2_CA")
|
||||||
PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO"
|
PEER_CONN_PARMS="$PEER_CONN_PARMS $TLSINFO"
|
||||||
fi
|
fi
|
||||||
# shift by two to get the next pair of peer/org parameters
|
# shift by two to get the next pair of peer/org parameters
|
||||||
shift; shift
|
shift
|
||||||
done
|
shift
|
||||||
# remove leading space for output
|
done
|
||||||
PEERS="$(echo -e "$PEERS" | sed -e 's/^[[:space:]]*//')"
|
# remove leading space for output
|
||||||
|
PEERS="$(echo -e "$PEERS" | sed -e 's/^[[:space:]]*//')"
|
||||||
}
|
}
|
||||||
|
|
||||||
# chaincodeInvoke <peer> <org> ...
|
# chaincodeInvoke <peer> <org> ...
|
||||||
# Accepts as many peer/org pairs as desired and requests endorsement from each
|
# Accepts as many peer/org pairs as desired and requests endorsement from each
|
||||||
chaincodeInvoke () {
|
chaincodeInvoke() {
|
||||||
parsePeerConnectionParameters $@
|
parsePeerConnectionParameters $@
|
||||||
res=$?
|
res=$?
|
||||||
verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "
|
verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters "
|
||||||
|
|
||||||
# while 'peer chaincode' command can get the orderer endpoint from the
|
# while 'peer chaincode' command can get the orderer endpoint from the
|
||||||
# peer (if join was successful), let's supply it directly as we know
|
# peer (if join was successful), let's supply it directly as we know
|
||||||
# it using the "-o" option
|
# it using the "-o" option
|
||||||
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
|
||||||
set -x
|
set -x
|
||||||
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc $PEER_CONN_PARMS -c '{"Args":["invoke","a","b","10"]}' >&log.txt
|
peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc $PEER_CONN_PARMS -c '{"Args":["invoke","a","b","10"]}' >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
else
|
else
|
||||||
set -x
|
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 -c '{"Args":["invoke","a","b","10"]}' >&log.txt
|
peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc $PEER_CONN_PARMS -c '{"Args":["invoke","a","b","10"]}' >&log.txt
|
||||||
res=$?
|
res=$?
|
||||||
set +x
|
set +x
|
||||||
fi
|
fi
|
||||||
cat log.txt
|
cat log.txt
|
||||||
verifyResult $res "Invoke execution on $PEERS failed "
|
verifyResult $res "Invoke execution on $PEERS failed "
|
||||||
echo "===================== Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME' ===================== "
|
echo "===================== Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME' ===================== "
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue