How to start a non-validating peer in Hyperledger?

2019-08-05 06:03发布

问题:

A validating peer can be started in Hyperledger using the following command:

docker run --rm -it -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 -e CORE_PEER_ID=vp1 -e CORE_PEER_ADDRESSAUTODETECT=true -e CORE_PEER_DISCOVERY_ROOTNODE=172.17.0.2:7051 hyperledger/fabric-peer peer node start

What is the command to start a non-validating peer?

回答1:

You need to make use of core.yaml file. If you carefully read core.yaml file you will see the following lines,

# Validator defines whether this peer is a validating peer or not, and if # it is enabled, what consensus plugin to load validator: enabled: true

Or you could implement membership services and create a peer with Non-validator privilege level.

This is what it says in membersrvc.yaml file,

Default users to be registered with the CA on first launch. The role is a binary OR of the different roles a user can have:

  • simple client such as a wallet: CLIENT
  • non-validating peer: PEER
  • validating client: VALIDATOR
  • auditing client: AUDITOR

and the levels,

The fields of each user are as follows: 1:client, 2: peer, 4: validator, 8: auditor

The following users are also available to register as non-validating peer in the same file,

 test_nvp0: 2 iywrPBDEPl0K bank_a
 test_nvp1: 2 DcYXuRSocuqd institution_a
 test_nvp2: 2 flpChShlY7xt bank_c
 test_nvp3: 2 jeruawMomclo bank_a
 test_nvp4: 2 RMYVxSZCk370 institution_a
 test_nvp5: 2 XHYVCIJGZGK7 bank_b
 test_nvp6: 2 4cIn63j8ahYp bank_a
 test_nvp7: 2 E7FAJUtWVn2h institution_a
 test_nvp8: 2 LJu8DkUilBEH bank_a
 test_nvp9: 2 VlEsBsiyXSjw institution_a

You can also look at the asset management example app which bootstraps a non-validating peer and constructs fabric confidential transactions to deploy, invoke and query the chaincode.



回答2:

using docker-compose to up peer using environment to override core.yaml -CORE_PEER_VALIDATOR_ENABLED = false

please do not only use docker run, docker-compose can set environments easily.