This post is part of Hyperledger Fabric network setup as mentioned below.
- Understand crypto-config.yaml file : Used to create cryptography material.
- Configtx.yaml file: Used to create genesis block and channel.
- Understand docker-compose.yaml file: Used to create docker container.
In our last blog, we discussed about crypto-config.yaml file and understand the structure of that file and then saw how to use that file to create cryptography material. In case you missed that, you can click here to read that article.
Now let's move to next step and that is understanding of configtx.yaml file. We split this post into two parts , first part will cover the details about configtx.yaml file and in second part, we will show you how to generate genesis and channel artifacts using that configtx.yaml file.
Let's deep dive and understand configtx file.yaml structure in detail.
Structure of configtx.yaml file
configtx.yaml file consist of
- organizations section
- orderers section
- applications section
- capabilities section
- profiles section
Organizations Section in configtx.yaml file
This section contains the organization details and that organization can be orderer or peer one. Below is one of the example from first-network sample.
As you see in below structure, very first tag is "Organizations:" and under that you can define any number of organizations as per the requirement.
As you see each organization has name, ID and MSPDir. Here MSPDir is location where cryptography material for that organization is stored.
It also has host and port details for it's anchor peer as well.
Orderer Section in configtx.yaml file
This section contains the details about orderer. This helps to create genesis block as well.
OrderType: This can have value as "solo" or "kafka". solo is used during development and kafka is used in production environment.
Addresses: This contains host and port details of orderer.
BatchTimeout: wait time before creating a batch. Orderer job is to create a batch of transactions so this is wait time for that.
Max Message Count: The maximum number of messages to permit in a batch
Absolute Max Bytes: The absolute maximum number of bytes allowed for the serialized messages in a batch.
Preferred Max Bytes: The preferred maximum number of bytes allowed for the serialized messages in a batch. A message larger than the preferred max bytes will result in a batch larger than preferred max bytes.
Application section in configtx.yaml file
Application is being referred in the genesis block. As shown below organizations is list of orgs which are defined as participants.
Capabilities section in configtx.yaml file
Capabilities is new feature in Hyperledger Fabric 1.1. The idea behind this is to avoid any impact to the network when there are different version of Fabric code running on nodes and everyone has same view of transaction.
Capabilities of different types as mentioned below.
Channel: these capabilities apply to both peer and orderers and are located in the root Channel group.
Orderer: apply to orderers only and are located in the Orderer group.
Application: apply to peers only and are located in the Application group.
Profile section in configtx.yaml file
Last and important section in configtx.yaml file is profile section. It consist of mainly two parts, one is genesis block details and second is channel details. Let's understand it with example.
TwoOrgsOrdererGenesis refers to genesis block and has required details under that. It contains capabilities of block, orderer details ( organization and capabilities), consortium details ( peer organizations).
TwoOrgsChannel refers to channel that helps to create required channel.