Hyperledger Fabric 核心模块(2)configtxgen configtx.yaml配置文件

1. Channel / 通道配置

要写入创世区块或配置交易的通道参数

Channel: &ChannelDefaults
    # 定义本层级的通道访问策略,其权威路径为 /Channel/
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: ANY Readers
        # Writes策略定义了调用Broadcast API提交交易的许可规则
        Writers:
            Type: ImplicitMeta
            Rule: ANY Writers
        # Admin策略定义了修改本层级配置的许可规则
        Admins:
            Type: ImplicitMeta
            Rule: MAJORITY Admins
    # Capabilities配置描通道层级的能力需求,这里直接引用
    # 前面Capabilities配置段中的ChannelCapabilities配置项
    Capabilities:
        <<: *ChannelCapabilities

2. Orderer / 排序节点配置

定义要编码写入创世区块或通道交易的排序节点参数,比如共识协议。

Orderer: &OrdererDefaults

    # 排序节点类型用来指定要启用的排序节点实现,不同的实现对应不同的共识算法。
    # 目前可用的类型为:solo和kafka
    OrdererType: solo
    Addresses:
        - orderer0.example.com:7050
    BatchTimeout: 2s
    BatchSize:
        MaxMessageCount: 10
        AbsoluteMaxBytes: 98 MB
        PreferredMaxBytes: 512 KB
    MaxChannels: 0
    Kafka:
        Brokers:
            - kafka0:9092
            - kafka1:9092
            - kafka2:9092
            - kafka3:9092
    Organizations:

    # 定义本层级的排序节点策略,其权威路径为 /Channel/Orderer/
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: ANY Readers
        Writers:
            Type: ImplicitMeta
            Rule: ANY Writers
        Admins:
            Type: ImplicitMeta
            Rule: MAJORITY Admins
        # BlockValidation配置项指定了哪些签名必须包含在区块中,以便对等节点进行验证
        BlockValidation:
            Type: ImplicitMeta
            Rule: ANY Writers
    # Capabilities配置描述排序节点层级的能力需求,这里直接引用
    # 前面Capabilities配置段中的OrdererCapabilities配置项
    Capabilities:
        <<: *OrdererCapabilities
eg.
Orderer: &OrdererDefaults
    OrdererType: etcdraft   
    Addresses:
        - orderer.example.com:7050
    EtcdRaft:
        Consenters:
        - Host: orderer.example.com
          Port: 7050
          ClientTLSCert: ../organizations/ordererOrganizations/example.com/orderers/
          orderer.example.com/tls/server.crt
          ServerTLSCert: ../organizations/ordererOrganizations/example.com/orderers/
          orderer.example.com/tls/server.crt
 
    BatchTimeout: 2s 
    BatchSize: 
        MaxMessageCount: 10 
        AbsoluteMaxBytes: 99 MB 
        PreferredMaxBytes: 512 KB 
    Organizations: 
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        # BlockValidation specifies what signatures must be included in the block
        # from the orderer for the peer to validate it.
        BlockValidation:
            Type: ImplicitMeta
            Rule: "ANY Writers"

3. Organizations / 组织机构配置

Organizations配置段用来定义组织机构实体,以便在后续配置中引用。例如,下面的配置文件中,定义了三个机构,可以分别使用ExampleCom、Org1ExampleCom和Org2ExampleCom引用其配置:

Organizations:

    - &ExampleCom
        Name: ExampleCom
        ID: example.com
        AdminPrincipal: Role.ADMIN
        MSPDir: ./ordererOrganizations/example.com/msp
        Policies:
            Readers:
                Type: Signature
                Rule: OR('example.com.member')
            Writers:
                Type: Signature
                Rule: OR('example.com.member')
            Admins:
                Type: Signature
                Rule: OR('example.com.admin')
            Endorsement:
                Type: Signature
                Rule: OR('example.com.member')

    - &Org1ExampleCom
        Name: Org1ExampleCom
        ID: org1.example.com
        MSPDir: ./peerOrganizations/org1.example.com/msp
        AdminPrincipal: Role.ADMIN
        AnchorPeers:
            - Host: peer0.org1.example.com
              Port: 7051
        Policies:
            Readers:
                Type: Signature
                Rule: OR('org1.example.com.member')
            Writers:
                Type: Signature
                Rule: OR('org1.example.com.member')
            Admins:
                Type: Signature
                Rule: OR('org1.example.com.admin')
            Endorsement:
                Type: Signature
                Rule: OR('org1.example.com.member')

    - &Org2ExampleCom
        Name: Org2ExampleCom
        ID: org2.example.com
        MSPDir: ./peerOrganizations/org2.example.com/msp
        AdminPrincipal: Role.ADMIN
        AnchorPeers:
            - Host: peer0.org2.example.com
              Port: 7051
        Policies:
            Readers:
                Type: Signature
                Rule: OR('org2.example.com.member')
            Writers:
                Type: Signature
                Rule: OR('org2.example.com.member')
            Admins:
                Type: Signature
                Rule: OR('org2.example.com.admin')
            Endorsement:
                Type: Signature
                Rule: OR('org2.example.com.member')

4. Application / 应用配置

Application配置段用来定义要写入创世区块或配置交易的应用参数

你可能感兴趣的:(Hyperledger,Fabric)