10

I have couple a questions regarding HF CLI docker container and some of CLI commands.

First of all, can someone explain the purpose of this container in context of docker container which is started alongside other docker containers required for HF ecosystem. How can I for example query my business network organisations, different peers, and chain-code status on those peers?

Second of all, when I install a chain code issuing peer chaincode install CLI command, to which peer is that code installed (if i have 5 peers attached to org1.example.com organisation, on which peer aforementioned command will install the targeted chain code)?

And third of all, if I have just one organization in my business network specification which handles multiple peers and channels, when I try to instantiate the installed code issuing peer chaincode instantiate command, how to specify the endorsement policy (http://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html) which has just one organisation in endorsement expression after the -P parameter?

Thank you for your help!

EDIT 1: Just one update regarding 3rd answer. In you have one organisation maintaining peers and channels when instantiating chaincode, you can omit the endorsing policy parameter (-p). In that case transaction will be endorsed if any peer endorses it

branko terzic
  • 654
  • 1
  • 8
  • 27

2 Answers2

12

Lots of great questions.

  1. the "cli" container's purpose is to run a peer process as a CLI . It is a bit confusing that the same process is both a client and a server, we may change that. Basically, when you run the peer chaincode commands, you are running the CLI. The peer node commands are the server commands. The cli container in our samples runs a script (scripts/script.sh) which in turn executes a series of CLI commands against the peer nodes.

  2. If you examine scripts/script.sh, you will find a setGlobals function that sets a few environment variables, including CORE_PEER_ADDRESS. This is the peer (server) to which the peer (CLI) will communicate when installing the chaincode.

  3. Actually, after further research, this is not possible, unfortunately. The gate syntax isn't yet implemented. You would need to simulate multiple orgs for this.

christo4ferris
  • 4,039
  • 1
  • 17
  • 30
  • had to revise response... the gate syntax is not yet implemented. – christo4ferris Oct 14 '17 at 12:24
  • Yes, ok, this is something I will wait for then. Tnx for the answer. – branko terzic Oct 14 '17 at 13:20
  • Just one update regarding 3rd answer. In you have one organisation maintaining peers and channels when instantiating chaincode, you can omit the endorsing policy parameter (-p). In that case transaction will be endorsed if any peer endorses it. – branko terzic Nov 06 '17 at 09:14
  • 1
    @christo4ferris, why would we prefer to execute the command via `cli` container instead of a direct execution inside the `peer` containers? – K_inverse Nov 12 '18 at 02:41
  • @K_inverse I have same question here. I can not figure out the reason why there is no chaincode in peer container but it still run successfully. Do you have some references? – KC. Oct 10 '19 at 11:49
  • when you install chaincode, you are essentially uploading the code (or binary) to the peer, and it is stored in the container's filesystem. Ideally you have mounted some persistent disk for this purpose. When you instantiate the chaincode, the chaincode code/binary is installed into a docker image which is subsequently launched and managed by the peer. – christo4ferris Oct 11 '19 at 16:44
0

Re the second part of this question.

Entering the CLI

docker exec -it cli bash

The bootstrapped peer for CLI is peer0.org1.example.com

Check which PEER you are on:

echo $CORE_PEER_ADDRESS

returns peer0.org1.example.com:7051

Change to peer1.org1:

export CORE_PEER_ADDRESS=peer1.org1.example.com:8051

Also applies to LOCALMSPID, MSPCONFIGPATH, etc

acc
  • 11
  • 1