YAML语言语法
首先需要了解YAML语言的语法。可以参考<<YAML 语言教程>>
configtx.yaml主要用到了以下语法:
符号 | 含义 |
---|---|
<< |
合并到当前数据 |
- |
数组 |
* |
别名 |
& |
锚点 |
configtx.yaml分析
configtx.yaml文件开头部分,主要配置项如下:
Profiles:
TwoOrgsOrdererGenesis:
Orderer:
<<: *OrdererDefaults
Organizations:
- *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
TwoOrgsChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org1
- *Org2
结构如下:
TwoOrgsOrdererGenesis
用来配置创世区块信息,TwoOrgsChannel
来配置初始交易信息。
TwoOrgsOrdererGenesis
配置项
传入profile参数的值为TwoOrgsOrdererGenesis
configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
定义两个东西:一个是Orderer
,另外一个是Consortiums
。
因为生成创世区块需要以下信息:
- Orderer信息
- 联盟信息
对于有一个Orderer,有两个组织Org1和Org2
Orderer配置
配置参数名 含义
OrdererType 类型solo或者kafka
Addresses Orderer地址
BatchTimeout 区块生成超时时间
MaxMessageCount 区块消息数量
AbsoluteMaxBytes 区块绝对最大字节数
PreferredMaxBytes 建议消息字节数。(暂时没有理解该字段,需翻源代码)
Brokers kafka地址
组织配置
配置参数名 | 含义 |
---|---|
Name | 组织名称 |
ID | MSP ID |
MSPDir | msp目录(关于MSP这块后续单独说明) |
AnchorPeers | 该组织的锚节点 |
TwoOrgsChannel
和TwoOrgsOrdererGenesis
差不多,不再说明。