Sunday, February 9, 2020

Adding new member to Hyperledger Fabric Organization

Objectives:

  • Create the peer definition
  • Deploy the peer
  • Add the peer to a channel


Creating the peer

cd fabric-samples/first-network


Edit the docker-compose.yml File


Please open docker-compose.yml in VS Code
The first thing we will do inside the docker-compose.yml file is to create a new container
definition (in the services section). Our container name will be peer1.org1.example.com .
We can specify a lot of the container configuration details to be very similar to peer1 since the two are from the same org (which have similar details). We can add the following information under the services section:


After you have added the peer1.org1.example.com details in the docker-compose.yml file, it should look like this:



One of the most important things to pay attention to here are the environment variables, which set values like the MSP identity, logging levels, etc. The other important thing is our volumes. The volumes section is how we expose/map our local folders, like the crypto-config or network-artifacts (aka our configuration directory) configuration folders to our Docker container for access.


Edit the crypto-config File

Since we are adding a new peer to Org1 , we must reconfigure what the template for Org1 is
going to be. We need to edit the generation template for Org1 so that it accommodates the
creation of two user identities (in the form of x509 certificates).
Open crypto-config.yaml in your preferred code editor.
What we are looking to edit is the value for Template.Count , which can be found under the
org1 section. We will be changing that value from 1 to 2. So that section should read:
Template:
Count: 2


Next, we need to re-generate the crypto certificates from our updated crypto-config using
cryptogen .This time, we can use a command to create new certificates without totally removing
the old ones.







Generating the Initial Configuration


First, we need to generate our genesis block.

../bin/configtxgen -profile OneOrgOrdererGenesis \
-outputBlock ./config/genesis.block

We can look at this newly created genesis block by using the inspectBlock command.


../bin/configtxgen -inspectBlock ./config/genesis.block

Start the Peer Container


Now, let’s use our docker-compose definition to quickly bring up peer1.org1


docker-compose -f docker-compose.yml up \
-d peer0.org1.example.com peer1.org1.example.com cli

Let’s return our peer containers to confirm they were started with no issues.


docker ps --filter name=peer

Since we joined peer0 in bootstrap, we must also do the same for peer1 . First, we must enter

into our peer container.

docker exec -it peer1.org1.example.com bash

We will set the identification Path to the Admin for Org1, so that we are authorized to pull and

edit the configuration. ( Note : The reason the path is /etc/hyperledger/msp is because we
mapped it that way at container startup using volumes.)

export
CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@ org1.example.
com/msp

Next, we need to pull the genesis block for the current channel we would like to append our
peer to.

peer channel fetch oldest allarewelcome . block - c allarewelcome \
-- orderer orderer.example.com:7050

Join the Peer to the Current Channel

peer channel join -b allarewelcome.block

Now, we can check and see if our peer is actually joined.

peer channel list

No comments:

Post a Comment

Making YouTube usable again

 YouTube has evolved from a platform for educational and entertaining content into a space filled with ads, distractions, and the ever-growi...