configtx.yaml配置文件解析

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

因为生成创世区块需要以下信息:

  1. Orderer信息
  2. 联盟信息

对于有一个Orderer,有两个组织Org1和Org2

Orderer配置

配置参数名    含义
OrdererType    类型solo或者kafka
Addresses    Orderer地址
BatchTimeout    区块生成超时时间
MaxMessageCount    区块消息数量
AbsoluteMaxBytes    区块绝对最大字节数
PreferredMaxBytes    建议消息字节数。(暂时没有理解该字段,需翻源代码)
Brokers    kafka地址

组织配置

配置参数名 含义
Name 组织名称
ID MSP ID
MSPDir msp目录(关于MSP这块后续单独说明)
AnchorPeers 该组织的锚节点

这里写图片描述

TwoOrgsChannelTwoOrgsOrdererGenesis差不多,不再说明。

转自https://blog.csdn.net/huiyanghu/article/details/82590230

猜你喜欢

转载自blog.csdn.net/xuhui_7810/article/details/84139626