Skip to content

Commit 715ddcf

Browse files
committed
[FAB-1938] Update documentation how to use peer cli
Peer cli command switched to use command line parameter to get the ordering service endpoint. This commit updates documentation files to reflect the change. Change-Id: Ib7d47d3bf6cb4cceb238a8514b0b1b960609448c Signed-off-by: Artem Barger <[email protected]>
1 parent c956be0 commit 715ddcf

File tree

3 files changed

+77
-21
lines changed

3 files changed

+77
-21
lines changed

docs/asset_cli.md

+36-10
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,64 @@ If successful, you should see the following in your terminal:
1414
```
1515
Send createChannel API to Ordering Service:
1616
```
17-
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer channel create -c myc2
17+
peer channel create -c myc2 -o orderer:7050
1818
```
1919
This will return a genesis block - `myc2.block` - that you can issue join commands with.
2020
Next, send a joinChannel API to `peer0` and pass in the genesis block as an argument.
2121
The channel is defined within the genesis block:
2222
```
23-
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 CORE_PEER_ADDRESS=peer0:7051 peer channel join -b myc2.block
23+
CORE_PEER_ADDRESS=peer0:7051 peer channel join -b myc2.block
2424
```
2525
To join the other peers to the channel, simply reissue the above command with `peer1`
2626
or `peer2` specified. For example:
2727
```
28-
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 CORE_PEER_ADDRESS=peer1:7051 peer channel join -b myc2.block
28+
CORE_PEER_ADDRESS=peer1:7051 peer channel join -b myc2.block
2929
```
3030
Once the peers have all joined the channel, you are able to issues queries against
3131
any peer without having to deploy chaincode to each of them.
3232

33-
## Use cli to deploy, invoke and query
33+
## Use cli to install, instantiate, invoke and query
3434

35-
Run the deploy command. This command is deploying a chaincode named `mycc` to
36-
`peer0` on the Channel ID `myc2`. The constructor message is initializing `a` and
37-
`b` with values of 100 and 200 respectively.
35+
Run the install command. This command is installing a chaincode named `mycc` to
36+
`peer0` on the Channel ID `myc2` and the chaincode version is v0.
3837
```
39-
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode deploy -C myc2 -n mycc -p github.com/hyperledger/fabric/examples -c '{"Args":["init","a","100","b","200"]}'
38+
CORE_PEER_ADDRESS=peer0:7051 peer chaincode deploy \
39+
-o orderer:7050 \
40+
-C myc2 \
41+
-n mycc \
42+
-p github.com/hyperledger/fabric/examples \
43+
-v v0
4044
```
45+
46+
Next we need to instantiate the chaincode by running the instatiate command on peer cli tool.
47+
The constructor message is initializing `a` and `b` with values of 100 and 200 respectively.
48+
49+
```bash
50+
CORE_PEER_ADDRESS=peer0:7051 peer chaincode instantiate \
51+
-o orderer:7050 \
52+
-C myc2 \
53+
-n mycc \
54+
-p github.com/hyperledger/fabric/examples \
55+
-v v0 \
56+
-c '{"Args":["init","a","100","b","200"]}'
57+
```
58+
4159
Run the invoke command. This invocation is moving 10 units from `a` to `b`.
4260
```
43-
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode invoke -C myc2 -n mycc -c '{"function":"invoke","Args":["move","a","b","10"]}'
61+
CORE_PEER_ADDRESS=peer0:7051 peer chaincode invoke \
62+
-C myc2 \
63+
-n mycc \
64+
-c '{"Args":["invoke","a", "b", 10]}' \
65+
-v v0
4466
```
4567
Run the query command. The invocation transferred 10 units from `a` to `b`, therefore
4668
a query against `a` should return the value 90.
4769
```
48-
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode query -C myc2 -n mycc -c '{"function":"invoke","Args":["query","a"]}'
70+
CORE_PEER_ADDRESS=peer0:7051 peer chaincode query \
71+
-C myc2 \
72+
-n mycc \
73+
-c '{"function":"invoke","Args":["query","a"]}' \
74+
-v v0
4975
```
5076
You can issue an `exit` command at any time to exit the cli container.
5177

docs/configtxgen.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This configuration file may be edited, or, individual properties may be overridd
2323
## Bootstrapping the orderer
2424
After creating a configuration profile as desired, simply invoke
2525
```
26-
configtxgen -profile &lt;profile_name&gt; -outputBlock &lt;genesis.blockname&gt;
26+
configtxgen -profile <profile_name> -outputBlock <genesis.blockname>;
2727
```
2828
This will produce a `genesis.block` file in the current directory. If you wish to skip writing the file simply do not pass `outputBlock`
2929

@@ -34,7 +34,7 @@ Then, to utilize this genesis block, before starting the orderer, simply specify
3434
The tool can also output a channel creation tx by executing
3535

3636
```
37-
configtxgen -profile &lt;profile_name&gt; -outputCreateChannelTx &lt;output.txname&gt;
37+
configtxgen -profile <profile_name> -outputCreateChannelTx <output.txname>
3838
```
3939

4040
This will output a marshaled `Envelope` message which may be sent to broadcast to create a channel.

docs/install_instantiate.md

+39-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ through vagrant, make sure you have followed the steps outlined in
99
fabric directory within your vagrant environment, execute the `make peer-docker`
1010
and `make orderer-docker` commands.
1111

12-
### Start the network of 2 peers, an orderer, and a CLI
12+
### Start the network of 2 peers, an orderer, and a CLI container
1313
Navigate to the fabric/docs directory in your vagrant environment and start your network:
1414
```bash
1515
docker-compose -f docker-2peer.yml up
@@ -33,7 +33,7 @@ root@ccd3308afc73:/opt/gopath/src/github.com/hyperledger/fabric/peer#
3333
### Create and join channel from the remote CLI
3434
From your second terminal, lets create a channel by the name of "myc":
3535
```bash
36-
peer channel create -c myc
36+
peer channel create -c myc -o orderer:5005
3737
```
3838
This will generate a genesis block - `myc.block` - and place it into the same directory
3939
from which you issued your `peer channel create` command. Now, from the same directory,
@@ -48,43 +48,69 @@ CORE_PEER_ADDRESS=peer1:7051 peer channel join -b myc.block
4848
From your second terminal, and still within the CLI container, issue the following
4949
command to install a chaincode named `mycc` with a version of `v0` onto `peer0`.
5050
```bash
51-
CORE_PEER_ADDRESS=peer0:7051 peer chaincode install -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0
51+
CORE_PEER_ADDRESS=peer0:7051 peer chaincode install \
52+
-o orderer:5005 \
53+
-n mycc \
54+
-p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 \
55+
-v v0
5256
```
5357

5458
### Instantiate the chaincode on the channel from the remote CLI
5559
Now, still within the cli container in your second terminal, instantiate the chaincode
5660
`mycc` with version `v0` onto `peer0`. This instantiation will initialize the chaincode
5761
with key value pairs of ["a","100"] and ["b","200"].
5862
```bash
59-
CORE_PEER_ADDRESS=peer0:7051 peer chaincode instantiate -C myc -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0 -c '{"Args":["init","a","100","b","200"]}'
63+
CORE_PEER_ADDRESS=peer0:7051 peer chaincode instantiate \
64+
-o orderer:5005 \
65+
-C myc \
66+
-n mycc \
67+
-p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 \
68+
-c '{"Args":["init","a","100","b","200"]}' \
69+
-v v0
6070
```
6171
__Continue operating within your second terminal for the remainder of the commands__
6272

6373
### Query for the value of "a" to make sure the chaincode container has successfully started
6474
Send a query to `peer0` for the value of key `"a"`:
6575
```bash
66-
CORE_PEER_ADDRESS=peer0:7051 peer chaincode query -C myc -n mycc -v v0 -c '{"Args":["query","a"]}'
76+
CORE_PEER_ADDRESS=peer0:7051 peer chaincode query \
77+
-C myc \
78+
-n mycc \
79+
-c '{"Args":["query","a"]}' \
80+
-v v0
6781
```
6882
This query should return "100".
6983

7084
### Invoke to make a state change
7185
Send an invoke request to `peer0` to move 10 units from "a" to "b":
7286
```bash
73-
CORE_PEER_ADDRESS=peer0:7051 peer chaincode invoke -C myc -n mycc -v v0 -c '{"Args":["invoke","a","b","10"]}'
87+
CORE_PEER_ADDRESS=peer0:7051 peer chaincode invoke \
88+
-C myc \
89+
-n mycc \
90+
-c '{"Args":["invoke","a","b","10"]}' \
91+
-v v0
7492
```
7593

7694
### Query on the second peer
7795
Issue a query against the key "a" to `peer1`. Recall that `peer1` has successfully
7896
joined the channel.
7997
```bash
80-
CORE_PEER_ADDRESS=peer1:7051 peer chaincode query -C myc -n mycc -v v0 -c '{"Args":["query","a"]}'
98+
CORE_PEER_ADDRESS=peer1:7051 peer chaincode query \
99+
-C myc \
100+
-n mycc \
101+
-c '{"Args":["query","a"]}' \
102+
-v v0
81103
```
82104
This will return an error response because `peer1` does not have the chaincode installed.
83105

84106
### Install on the second peer
85107
Now add the chaincode to `peer1` so that you can successfully perform read/write operations.
86108
```bash
87-
CORE_PEER_ADDRESS=peer1:7051 peer chaincode install -n mycc -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -v v0
109+
CORE_PEER_ADDRESS=peer1:7051 peer chaincode install \
110+
-o orderer:5005 \
111+
-n mycc \
112+
-p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 \
113+
-v v0
88114
```
89115
__Note__: The initial instantiation applies to all peers in the channel, and is
90116
affected upon any peer that has the chaincode installed. Therefore, we installed
@@ -97,7 +123,11 @@ chaincode must be installed on any peer receiving endorsement requests for that
97123
### Query on the second peer
98124
Now issue the same query request to `peer1`.
99125
```bash
100-
CORE_PEER_ADDRESS=peer1:7051 peer chaincode query -C myc -n mycc -v v0 -c '{"Args":["query","a"]}'
126+
CORE_PEER_ADDRESS=peer1:7051 peer chaincode query \
127+
-C myc \
128+
-n mycc \
129+
-c '{"Args":["query","a"]}' \
130+
-v v0
101131
```
102132
Query will now succeed.
103133

0 commit comments

Comments
 (0)