1
1
#! /bin/bash
2
2
3
- # find address of orderer and peers in your network
4
- ORDERER0_IP=` perl -e ' use Socket; $a = inet_ntoa(inet_aton("orderer0")); print "$a\n";' `
5
- PEER0_IP=` perl -e ' use Socket; $a = inet_ntoa(inet_aton("peer0")); print "$a\n";' `
6
- PEER1_IP=` perl -e ' use Socket; $a = inet_ntoa(inet_aton("peer1")); print "$a\n";' `
7
- PEER2_IP=` perl -e ' use Socket; $a = inet_ntoa(inet_aton("peer2")); print "$a\n";' `
8
- PEER3_IP=` perl -e ' use Socket; $a = inet_ntoa(inet_aton("peer2")); print "$a\n";' `
9
-
10
- echo " -----------------------------------------"
11
- echo " Orderer0 IP $ORDERER0_IP "
12
- echo " PEER0 IP $PEER0_IP "
13
- echo " PEER1 IP $PEER1_IP "
14
- echo " PEER2 IP $PEER2_IP "
15
- echo " PEER3 IP $PEER3_IP "
16
- echo " -----------------------------------------"
17
-
18
3
CHANNEL_NAME=" $1 "
19
4
: ${CHANNEL_NAME:= " mychannel" }
20
5
: ${TIMEOUT:= " 60" }
@@ -38,8 +23,6 @@ setGlobals () {
38
23
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer$1 /localMspConfig
39
24
CORE_PEER_ADDRESS=peer$1 :7051
40
25
41
-
42
-
43
26
if [ $1 -eq 0 -o $1 -eq 1 ] ; then
44
27
CORE_PEER_LOCALMSPID=" Org0MSP"
45
28
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer$1 /localMspConfig/cacerts/peerOrg0.pem
@@ -53,7 +36,12 @@ setGlobals () {
53
36
createChannel () {
54
37
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig
55
38
CORE_PEER_LOCALMSPID=" OrdererMSP"
56
- peer channel create -o orderer0:7050 -c $CHANNEL_NAME -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >& log.txt
39
+
40
+ if [ -z " $CORE_PEER_TLS_ENABLED " -o " $CORE_PEER_TLS_ENABLED " = " false" ]; then
41
+ peer channel create -o orderer0:7050 -c $CHANNEL_NAME -f crypto/orderer/channel.tx >& log.txt
42
+ else
43
+ peer channel create -o orderer0:7050 -c $CHANNEL_NAME -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >& log.txt
44
+ fi
57
45
res=$?
58
46
cat log.txt
59
47
verifyResult $res " Channel creation failed"
@@ -101,7 +89,11 @@ installChaincode () {
101
89
instantiateChaincode () {
102
90
PEER=$1
103
91
setGlobals $PEER
104
- peer chaincode instantiate -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c ' {"Args":["init","a","100","b","200"]}' -P " OR ('Org0MSP.member','Org1MSP.member')" >& log.txt
92
+ if [ -z " $CORE_PEER_TLS_ENABLED " -o " $CORE_PEER_TLS_ENABLED " = " false" ]; then
93
+ peer chaincode instantiate -o orderer0:7050 -C $CHANNEL_NAME -n mycc -v 1.0 -c ' {"Args":["init","a","100","b","200"]}' -P " OR ('Org0MSP.member','Org1MSP.member')" >& log.txt
94
+ else
95
+ peer chaincode instantiate -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 1.0 -c ' {"Args":["init","a","100","b","200"]}' -P " OR ('Org0MSP.member','Org1MSP.member')" >& log.txt
96
+ fi
105
97
res=$?
106
98
cat log.txt
107
99
verifyResult $res " Chaincode instantiation on PEER$PEER on channel '$CHANNEL_NAME ' failed"
@@ -139,7 +131,11 @@ chaincodeQuery () {
139
131
140
132
chaincodeInvoke () {
141
133
PEER=$1
142
- peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c ' {"Args":["invoke","a","b","10"]}' >& log.txt
134
+ if [ -z " $CORE_PEER_TLS_ENABLED " -o " $CORE_PEER_TLS_ENABLED " = " false" ]; then
135
+ peer chaincode invoke -o orderer0:7050 -C $CHANNEL_NAME -n mycc -c ' {"Args":["invoke","a","b","10"]}' >& log.txt
136
+ else
137
+ peer chaincode invoke -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c ' {"Args":["invoke","a","b","10"]}' >& log.txt
138
+ fi
143
139
res=$?
144
140
cat log.txt
145
141
verifyResult $res " Invoke execution on PEER$PEER failed "
0 commit comments