Adding peer to a running network

Sunil Suseelan
Coinmonks
5 min readFeb 17, 2020

--

Hello Folks,

Recently I discussed with you guys about various certification options in Blockchain and we saw in detail what is the pattern for Hyperledger fabric certification exam.

One such topic that is part of the problem-solving questions in Hyperledger fabric exam is adding a new peer to an existing network, this is something that is very commonly required in day to day implementation of a Hyperledger fabric network and that’s why holds a place in the certification exam but the this topic doesn’t hold a place in Hyperledger fabric product documentation so here we are going to talk about how can we add an peer to an Organization which is already part of a network and detail out the required steps

So, before we start, I have already done the groundwork and the sample BYFN network is up and running

You can do the same by following the Hyperledger fabric documentation.

Now we will start the process to add a peer to an existing network.

Step 1: Updating the crypto-config file, if you are aware about the steps to set up network “crypto-config” plays an important role and is the first step to start with so it’s the same for adding peer

The count property of crypto-config file defines the number of peers for any org defined in the file so adding a new peer to org first expects the count to be increased by the number of new peers needed

Here in the sample byfn network folder for crypto-config file we will increase the count from 2 to 3 since we want to add a new peer

Steps 2: Generate certificates for new peer, now since the new peer would belong to an existing org and we are extending the org with one more peer, we will run cryptogen tool again on the same crypto-config file but this time instead of generate we would use the extend flag for cryptogen tool

This command would simply update the existing crypto-config folder of certificates that had identity certificates initially only for two peers, and now will carry the newly created certificates of our new peer

Here you can see the new peer folder been added

Step 3: Setting up container for new Peer.

In this next step we need to update the docker-compose file of our network to include the new peer container configuration

For the ease of inputting new peer configuration, we would just refer the existing peer container configuration and replicate the same changing the peer name

docker-compose-cli.yaml

Next file is: docker-compose-base.yaml

While replicating the configuration keep in mind to update the port, volume, container name exactly and not to update the CORE_PEER_GOSSIP_BOOTSTRAP

Step 4: Now the further steps are very similar to starting the network

We are going to run the same command as to start the network and this time the docker composer will read the configuration file but this time the new peer’s configuration is read and since it doesn’t exist composer will create the container for new peer, using the configuration we added.

Now we can see the new peer container running

Step 5: Next we’ll connect this new peer to the channel

Let’s enter the CLI container, here we would find the genesis block of our channel that we created earlier for other peers to join, we will use the same block

Set the environment variable pointing to new peer

And then connect the new peer to existing channel with below command

If we try to query the chaincode already running on the channel through this peer, this will fail since we don’t have the chaincode installed on this peer

Step 6: Now we would set chaincode on this peer and complete our tutorial

We would install chaincode with below command,

Step7: In the end we will invoke the chaincode installed on our new peer, this would create a new chaincode container for our peer and would take some time to process for the first ever call

So that’s it, we have a new peer for org1 added to an existing running network.

Get Best Software Deals Directly In Your Inbox

--

--

Sunil Suseelan
Coinmonks

Let me Brag about myself, something that no one does on social platform ;). Well to be frank am not a super technical guy, but I strive to do my best