Skip to content

Commit 0806151

Browse files
author
NIKHIL E GUPTA
committed
[FAB-15098] update byfn couchDB
Update BYFN couchDB marbles secrion for new lifecycle. Change-Id: I8bdbc82a2722b36878a74a70586d120e3f8f3ae3 Signed-off-by: NIKHIL E GUPTA <negupta@us.ibm.com>
1 parent 66aee3f commit 0806151

File tree

1 file changed

+77
-20
lines changed

1 file changed

+77
-20
lines changed

docs/source/build_network.rst

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,9 +1050,9 @@ What's happening behind the scenes?
10501050

10511051
- A query against the value of "a" is issued to ``peer0.org2.example.com``.
10521052
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".
10561056

10571057
- An invoke is sent to ``peer0.org1.example.com`` and ``peer0.org2.example.com``
10581058
to move "10" from "a" to "b"
@@ -1188,6 +1188,11 @@ The same chaincode functions are available with CouchDB, however, there is the
11881188
added ability to perform rich and complex queries against the state database
11891189
data content contingent upon the chaincode data being modeled as JSON.
11901190

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+
11911196
To use CouchDB instead of the default database (goleveldb), follow the same
11921197
procedures outlined earlier for generating the artifacts, except when starting
11931198
the network pass ``docker-compose-couch.yaml`` as well:
@@ -1208,35 +1213,88 @@ the network pass ``docker-compose-couch.yaml`` as well:
12081213

12091214
You can use **abstore** chaincode against the CouchDB state database
12101215
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.
12141221

12151222
We will follow the same process to create and join the channel as outlined in the
12161223
:ref:`peerenvvars` section above. Once you have joined your peer(s) to the
12171224
channel, use the following steps to interact with the **marbles02** chaincode:
12181225

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:
12201250

12211251
.. code:: bash
12221252
12231253
# be sure to modify the $CHANNEL_NAME variable accordingly for the instantiate command
12241254
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
12271256
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:
12291288

12301289
.. code:: bash
12311290
12321291
# be sure to modify the $CHANNEL_NAME variable accordingly
12331292
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"]}'
12401298
12411299
- If you chose to map the CouchDB ports in docker-compose, you can now view
12421300
the state database through the CouchDB web interface (Fauxton) by opening
@@ -1352,10 +1410,9 @@ Troubleshooting
13521410
docker rm -f $(docker ps -aq)
13531411
docker rmi -f $(docker images -q)
13541412
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.
13591416

13601417
- If you see the below error:
13611418

0 commit comments

Comments
 (0)