configtx.yaml简介
transaction的英文缩写是TX(表示交易),configtx表示交易配置,所以和交易相关的配置,如应用通道、锚节点、Orderer服务等,都是在configtx.yaml文件中配置的。它主要生成通道创世区块${CHANNEL_NAME}.block。
configtx.yaml 配置文件一般包括若干字段:Organizations、Capabilities、Channel、Orderer、Application和Profiles。用户可指定直接使用其中某个Profile,自动引用其他字段中的定义。
configtx.yaml分析主要配置如下
配置项 | 作用 |
---|---|
Organizations | 一系列组织的结构定义,包括名称、MSP路径、读写和管理权限、锚节点等,可被Profiles等部分引用 |
Capabilities | 一系列能力定义,如通道、排序服务、应用等的能力,可被Channel等部分引用 |
Channel | 定义通道相关的默认配置,包括读写和管理权限、能力等,可被Prof iles等部分引用 |
Orderer | 与排序服务相关的配置,包括排序服务类型、地址、切块时间和大小、参与排序服务的组织、权限和能力,可被Profiles等部分引用 |
Application | 与应用通道相关的配置,主要包括默认访问控制权限、参与应用网络的组织、权限和能力,可被Prof iles等部分引用 |
Profiles | 一系列的配置定义,包括指定排序服务配置、应用配置和联盟配置等,直接被configtxgen工具指定使用 |
Organizations部分
组织配置,用来定义不同的组织机构实体,以便后续配置中引用。例如以下配置文件中,定义了三个机构:OrdererOrg、Org1、Org2
MSP(Membership Service Provider)是一个组织的身份标识,在Fabric中组织是由MSP来唯一标识的;
Organizations:
# SampleOrg defines an MSP using the sampleconfig. It should never be used
# in production but may be used as a template for other definitions.
- &OrdererOrg
# Name is the key by which this org will be referenced in channel
# configuration transactions.
# Name can include alphanumeric characters as well as dots and dashes.
Name: OrdererOrg
# SkipAsForeign can be set to true for org definitions which are to be
# inherited from the orderer system channel during channel creation. This
# is especially useful when an admin of a single org without access to the
# MSP directories of the other orgs wishes to create a channel. Note
# this property must always be set to false for orgs included in block
# creation.
SkipAsForeign: false
# ID is the key by which this org's MSP definition will be referenced.
# ID can include alphanumeric characters as well as dots and dashes.
ID: OrdererMSP
# MSPDir is the filesystem path which contains the MSP configuration.
MSPDir: /usr/project/fabric-docker-multiple/crypto-config/ordererOrganizations/example.com/msp
# Policies defines the set of policies at this level of the config tree
# For organization policies, their canonical path is usually
# /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
Policies:
Readers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
# If your MSP is configured with the new NodeOUs, you might
# want to use a more specific rule like the following:
# Rule: "OR('SampleOrg.admin', 'SampleOrg.peer', 'SampleOrg.client')"
Writers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
# If your MSP is configured with the new NodeOUs, you might
# want to use a more specific rule like the following:
# Rule: "OR('SampleOrg.admin', 'SampleOrg.client')"
Admins:
Type: Signature
Rule: "OR('OrdererMSP.admin')"
Endorsement:
Type: Signature
Rule: "OR('OrdererMSP.member')"
# OrdererEndpoints is a list of all orderers this org runs which clients
# and peers may to connect to to push transactions and receive blocks respectively.
OrdererEndpoints:
- "orderer0.example.com:7050"
- "orderer1.example.com:8050"
- "orderer2.example.com:9050"
# AnchorPeers defines the location of peers which can be used for
# cross-org gossip communication.
#
# NOTE: this value should only be set when using the deprecated
# `configtxgen --outputAnchorPeersUpdate` command. It is recommended
# to instead use the channel configuration update process to set the
# anchor peers for each organization.
#AnchorPeers:
# - Host: 127.0.0.1
# Port: 7051
-