@@ -1050,9 +1050,9 @@ What's happening behind the scenes?
1050
1050
1051
1051
- A query against the value of "a" is issued to ``peer0.org2.example.com ``.
1052
1052
A container for Org2 peer0 by the name of ``dev-peer0.org2.example.com-mycc-1.0 ``
1053
- was started when the chaincode was instantiated . The result
1054
- of the query is returned. No write operations have occurred, so
1055
- a query against "a" will still return a value of "100".
1053
+ was started when the chaincode was initialized . The result of the query is
1054
+ returned. No write operations have occurred, so a query against "a" will
1055
+ still return a value of "100".
1056
1056
1057
1057
- An invoke is sent to ``peer0.org1.example.com `` and ``peer0.org2.example.com ``
1058
1058
to move "10" from "a" to "b"
@@ -1188,6 +1188,11 @@ The same chaincode functions are available with CouchDB, however, there is the
1188
1188
added ability to perform rich and complex queries against the state database
1189
1189
data content contingent upon the chaincode data being modeled as JSON.
1190
1190
1191
+ .. note :: The Fabric chaincode lifecycle that is being introduced in the v2.0
1192
+ Alpha release does not support using indexes with CouchDB. However,
1193
+ you can still use CouchDB as the state database and follow the steps
1194
+ below.
1195
+
1191
1196
To use CouchDB instead of the default database (goleveldb), follow the same
1192
1197
procedures outlined earlier for generating the artifacts, except when starting
1193
1198
the network pass ``docker-compose-couch.yaml `` as well:
@@ -1208,35 +1213,88 @@ the network pass ``docker-compose-couch.yaml`` as well:
1208
1213
1209
1214
You can use **abstore ** chaincode against the CouchDB state database
1210
1215
using the steps outlined above, however in order to exercise the CouchDB query
1211
- capabilities you will need to use a chaincode that has data modeled as JSON,
1212
- (e.g. **marbles02 **). You can locate the **marbles02 ** chaincode in the
1213
- ``fabric/examples/chaincode/go `` directory.
1216
+ capabilities you will need to use a chaincode that has data modeled as JSON.
1217
+ The sample chaincode **marbles02 ** has been written to demostrate the queries
1218
+ you can issue from your chaincode if you are using a CouchDB database. You can
1219
+ locate the **marbles02 ** chaincode in the ``fabric/examples/chaincode/go ``
1220
+ directory.
1214
1221
1215
1222
We will follow the same process to create and join the channel as outlined in the
1216
1223
:ref: `peerenvvars ` section above. Once you have joined your peer(s) to the
1217
1224
channel, use the following steps to interact with the **marbles02 ** chaincode:
1218
1225
1219
- - Install and instantiate the chaincode on ``peer0.org1.example.com ``:
1226
+
1227
+ - Package and install the chaincode on ``peer0.org1.example.com ``:
1228
+
1229
+ .. code :: bash
1230
+
1231
+ peer lifecycle chaincode package marbles.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/marbles02/go/ --lang golang --label marbles_1
1232
+ peer lifecycle chaincode install marbles.tar.gz
1233
+
1234
+ The install command will return a chaincode packageID that you will use to
1235
+ approve a chaincode definition.
1236
+
1237
+ .. code :: bash
1238
+
1239
+ 2019-04-08 20:10:32.568 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:< status:200 payload:" \nJmarbles_1:cfb623954827aef3f35868764991cc7571b445a45cfd3325f7002f14156d61ae\022\tmarbles_1" >
1240
+ 2019-04-08 20:10:32.568 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: marbles_1:cfb623954827aef3f35868764991cc7571b445a45cfd3325f7002f14156d61ae
1241
+
1242
+ - Save the packageID as an environment variable so you can pass it to future
1243
+ commands:
1244
+
1245
+ .. code :: bash
1246
+
1247
+ CC_PACKAGE_ID=marbles_1:3a8c52d70c36313cfebbaf09d8616e7a6318ababa01c7cbe40603c373bcfe173
1248
+
1249
+ - Approve a chaincode definition as Org1:
1220
1250
1221
1251
.. code :: bash
1222
1252
1223
1253
# be sure to modify the $CHANNEL_NAME variable accordingly for the instantiate command
1224
1254
1225
- peer chaincode install -n marbles -v 1.0 -p github.com/hyperledger/fabric-samples/chaincode/marbles02/go
1226
- peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -v 1.0 -c ' {"Args":["init"]}' -P " OR ('Org0MSP.peer','Org1MSP.peer')"
1255
+ peer lifecycle chaincode approveformyorg --channelID $CHANNEL_NAME --name marbles --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --waitForEvent
1227
1256
1228
- - Create some marbles and move them around:
1257
+ - Install the chaincode on ``peer0.org2.example.com ``:
1258
+
1259
+ .. code :: bash
1260
+
1261
+ CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp
1262
+ CORE_PEER_ADDRESS=peer0.org2.example.com:9051
1263
+ CORE_PEER_LOCALMSPID=" Org2MSP"
1264
+ CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
1265
+ peer lifecycle chaincode install marbles.tar.gz
1266
+
1267
+ - Approve a chaincode definition as Org2, and then commit the definition to the
1268
+ channel:
1269
+
1270
+ .. code :: bash
1271
+
1272
+ # be sure to modify the $CHANNEL_NAME variable accordingly for the instantiate command
1273
+
1274
+ peer lifecycle chaincode approveformyorg --channelID $CHANNEL_NAME --name marbles --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --waitForEvent
1275
+ peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID $CHANNEL_NAME --name marbles --version 1.0 --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --waitForEvent
1276
+
1277
+ - We can now create some marbles. The first invoke of the chaincode will start
1278
+ the chaincode container. You may need to wait for the container to start.
1279
+
1280
+ .. code :: bash
1281
+
1282
+ # be sure to modify the $CHANNEL_NAME variable accordingly
1283
+
1284
+ peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ' {"Args":["initMarble","marble1","blue","35","tom"]}'
1285
+
1286
+ Once the container has started, you can issue additional commands to create
1287
+ some marbles and move them around:
1229
1288
1230
1289
.. code :: bash
1231
1290
1232
1291
# be sure to modify the $CHANNEL_NAME variable accordingly
1233
1292
1234
- peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c ' {"Args":["initMarble","marble1","blue","35","tom"]}'
1235
- peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c ' {"Args":["initMarble","marble2","red","50","tom"]}'
1236
- peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c ' {"Args":["initMarble","marble3","blue","70","tom"]}'
1237
- peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c ' {"Args":["transferMarble","marble2","jerry"]}'
1238
- peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c ' {"Args":["transferMarblesBasedOnColor","blue","jerry"]}'
1239
- peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles -c ' {"Args":["delete","marble1"]}'
1293
+ peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ' {"Args":["initMarble","marble2","red","50","tom"]}'
1294
+ peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ' {"Args":["initMarble","marble3","blue","70","tom"]}'
1295
+ peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ' {"Args":["transferMarble","marble2","jerry"]}'
1296
+ peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ' {"Args":["transferMarblesBasedOnColor","blue","jerry"]}'
1297
+ peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n marbles --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ' {"Args":["delete","marble1"]}'
1240
1298
1241
1299
- If you chose to map the CouchDB ports in docker-compose, you can now view
1242
1300
the state database through the CouchDB web interface (Fauxton) by opening
@@ -1352,10 +1410,9 @@ Troubleshooting
1352
1410
docker rm -f $( docker ps -aq)
1353
1411
docker rmi -f $( docker images -q)
1354
1412
1355
- - If you see errors on your create, instantiate, invoke or query commands, make
1356
- sure you have properly updated the channel name and chaincode name. There
1357
- are placeholder values in the supplied sample commands.
1358
-
1413
+ - If you see errors on your create, approve, commit, invoke or query commands,
1414
+ make sure you have properly updated the channel name and chaincode name.
1415
+ There are placeholder values in the supplied sample commands.
1359
1416
1360
1417
- If you see the below error:
1361
1418
0 commit comments