@@ -50,7 +50,7 @@ ORG2_MSPCONFIGPATH=${CONFIG_ROOT}/crypto/peerOrganizations/org2.example.com/user
50
50
ORG2_TLS_ROOTCERT_FILE=${CONFIG_ROOT} /crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
51
51
ORDERER_TLS_ROOTCERT_FILE=${CONFIG_ROOT} /crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
52
52
53
- PEER_ORG1 =" docker exec
53
+ PEER0_ORG1 =" docker exec
54
54
-e CORE_PEER_LOCALMSPID=Org1MSP
55
55
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051
56
56
-e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH}
61
61
--cafile=${ORDERER_TLS_ROOTCERT_FILE}
62
62
--orderer=orderer.example.com:7050"
63
63
64
- PEER_ORG2=" docker exec
64
+ PEER1_ORG1=" docker exec
65
+ -e CORE_PEER_LOCALMSPID=Org1MSP
66
+ -e CORE_PEER_ADDRESS=peer1.org1.example.com:8051
67
+ -e CORE_PEER_MSPCONFIGPATH=${ORG1_MSPCONFIGPATH}
68
+ -e CORE_PEER_TLS_ROOTCERT_FILE=${ORG1_TLS_ROOTCERT_FILE}
69
+ cli
70
+ peer
71
+ --tls=true
72
+ --cafile=${ORDERER_TLS_ROOTCERT_FILE}
73
+ --orderer=orderer.example.com:7050"
74
+
75
+ PEER0_ORG2=" docker exec
65
76
-e CORE_PEER_LOCALMSPID=Org2MSP
66
77
-e CORE_PEER_ADDRESS=peer0.org2.example.com:9051
67
78
-e CORE_PEER_MSPCONFIGPATH=${ORG2_MSPCONFIGPATH}
72
83
--cafile=${ORDERER_TLS_ROOTCERT_FILE}
73
84
--orderer=orderer.example.com:7050"
74
85
86
+ PEER1_ORG2=" docker exec
87
+ -e CORE_PEER_LOCALMSPID=Org2MSP
88
+ -e CORE_PEER_ADDRESS=peer1.org2.example.com:10051
89
+ -e CORE_PEER_MSPCONFIGPATH=${ORG2_MSPCONFIGPATH}
90
+ -e CORE_PEER_TLS_ROOTCERT_FILE=${ORG2_TLS_ROOTCERT_FILE}
91
+ cli
92
+ peer
93
+ --tls=true
94
+ --cafile=${ORDERER_TLS_ROOTCERT_FILE}
95
+ --orderer=orderer.example.com:7050"
96
+
75
97
echo " Packaging smart contract on peer0.org1.example.com"
76
- ${PEER_ORG1 } lifecycle chaincode package \
98
+ ${PEER0_ORG1 } lifecycle chaincode package \
77
99
fabcar.tar.gz \
78
100
--path " $CC_SRC_PATH " \
79
101
--lang " $CC_RUNTIME_LANGUAGE " \
80
102
--label fabcarv1
81
103
82
104
echo " Installing smart contract on peer0.org1.example.com"
83
- ${PEER_ORG1} lifecycle chaincode install \
105
+ ${PEER0_ORG1} lifecycle chaincode install \
106
+ fabcar.tar.gz
107
+
108
+ echo " Installing smart contract on peer1.org1.example.com"
109
+ ${PEER1_ORG1} lifecycle chaincode install \
84
110
fabcar.tar.gz
85
111
86
112
echo " Determining package ID for smart contract on peer0.org1.example.com"
87
113
REGEX=' Package ID: (.*), Label: fabcarv1'
88
- if [[ ` ${PEER_ORG1 } lifecycle chaincode queryinstalled` =~ $REGEX ]]; then
114
+ if [[ ` ${PEER0_ORG1 } lifecycle chaincode queryinstalled` =~ $REGEX ]]; then
89
115
PACKAGE_ID_ORG1=${BASH_REMATCH[1]}
90
116
else
91
117
echo Could not find package ID for fabcarv1 chaincode on peer0.org1.example.com
92
118
exit 1
93
119
fi
94
120
95
121
echo " Approving smart contract for org1"
96
- ${PEER_ORG1 } lifecycle chaincode approveformyorg \
122
+ ${PEER0_ORG1 } lifecycle chaincode approveformyorg \
97
123
--package-id ${PACKAGE_ID_ORG1} \
98
124
--channelID mychannel \
99
125
--name fabcar \
@@ -103,26 +129,29 @@ ${PEER_ORG1} lifecycle chaincode approveformyorg \
103
129
--waitForEvent
104
130
105
131
echo " Packaging smart contract on peer0.org2.example.com"
106
- ${PEER_ORG2 } lifecycle chaincode package \
132
+ ${PEER0_ORG2 } lifecycle chaincode package \
107
133
fabcar.tar.gz \
108
134
--path " $CC_SRC_PATH " \
109
135
--lang " $CC_RUNTIME_LANGUAGE " \
110
136
--label fabcarv1
111
137
112
138
echo " Installing smart contract on peer0.org2.example.com"
113
- ${PEER_ORG2} lifecycle chaincode install fabcar.tar.gz
139
+ ${PEER0_ORG2} lifecycle chaincode install fabcar.tar.gz
140
+
141
+ echo " Installing smart contract on peer1.org2.example.com"
142
+ ${PEER1_ORG2} lifecycle chaincode install fabcar.tar.gz
114
143
115
144
echo " Determining package ID for smart contract on peer0.org2.example.com"
116
145
REGEX=' Package ID: (.*), Label: fabcarv1'
117
- if [[ ` ${PEER_ORG2 } lifecycle chaincode queryinstalled` =~ $REGEX ]]; then
146
+ if [[ ` ${PEER0_ORG2 } lifecycle chaincode queryinstalled` =~ $REGEX ]]; then
118
147
PACKAGE_ID_ORG2=${BASH_REMATCH[1]}
119
148
else
120
149
echo Could not find package ID for fabcarv1 chaincode on peer0.org2.example.com
121
150
exit 1
122
151
fi
123
152
124
153
echo " Approving smart contract for org2"
125
- ${PEER_ORG2 } lifecycle chaincode approveformyorg \
154
+ ${PEER0_ORG2 } lifecycle chaincode approveformyorg \
126
155
--package-id ${PACKAGE_ID_ORG2} \
127
156
--channelID mychannel \
128
157
--name fabcar \
@@ -132,7 +161,7 @@ ${PEER_ORG2} lifecycle chaincode approveformyorg \
132
161
--waitForEvent
133
162
134
163
echo " Committing smart contract"
135
- ${PEER_ORG1 } lifecycle chaincode commit \
164
+ ${PEER0_ORG1 } lifecycle chaincode commit \
136
165
--channelID mychannel \
137
166
--name fabcar \
138
167
--version 1.0 \
@@ -145,15 +174,20 @@ ${PEER_ORG1} lifecycle chaincode commit \
145
174
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}
146
175
147
176
echo " Submitting initLedger transaction to smart contract on mychannel"
148
- ${PEER_ORG1} chaincode invoke \
177
+ echo " The transaction is sent to all of the peers so that chaincode is built before receiving the following requests"
178
+ ${PEER0_ORG1} chaincode invoke \
149
179
-C mychannel \
150
180
-n fabcar \
151
181
-c ' {"function":"initLedger","Args":[]}' \
152
182
--waitForEvent \
153
183
--waitForEventTimeout 300s \
154
184
--peerAddresses peer0.org1.example.com:7051 \
185
+ --peerAddresses peer1.org1.example.com:8051 \
155
186
--peerAddresses peer0.org2.example.com:9051 \
187
+ --peerAddresses peer1.org2.example.com:10051 \
188
+ --tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \
156
189
--tlsRootCertFiles ${ORG1_TLS_ROOTCERT_FILE} \
190
+ --tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE} \
157
191
--tlsRootCertFiles ${ORG2_TLS_ROOTCERT_FILE}
158
192
159
193
cat << EOF
0 commit comments