hyperledger 结构中 configtx.yaml 中的配置文件部分是什么

Nik*_*ili 3 hyperledger-fabric hyperledger-composer

TwoOrgsOrdererGenesis:
        <<: *ChannelDefaults
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2

    TwoOrgsChannel:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
            Capabilities:
                <<: *ApplicationCapabilities
Run Code Online (Sandbox Code Playgroud)

该部分到底是什么意思?

让我们开始讨论第一个配置文件:TwoOrgsOrdererGenesis。任何人都可以向我解释这意味着什么?什么是财团?为什么在示例中,创世块设置和通道设置有一个 SampleConsortium 名称?我检查了创世区块的内容,但找不到任何具有该名称的内容。 我用一种非常理解的语言发布的关于整个代码的很好的解释将是如此令人愉快和光荣。谢谢

Moh*_*sem 5

在这个文件中,我们配置了创世块,你可以通过它来构建自己的网络,所以让我们深入了解一些细节。

组织领域:看起来像这样

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
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: OrdererOrg

    # ID to load the MSP definition as
    ID: OrdererMSP

    # MSPDir is the filesystem path which contains the MSP configuration
    MSPDir: crypto-config/ordererOrganizations/example.com/msp

- &Org1
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: Org1MSP

    # ID to load the MSP definition as
    ID: Org1MSP

    MSPDir: crypto-config/peerOrganizations/org1.example.com/msp

    AnchorPeers:
        # AnchorPeers defines the location of peers which can be used
        # for cross org gossip communication.  Note, this value is only
        # encoded in the genesis block in the Application section context
        - Host: peer0.org1.example.com
          Port: 7051

- &Org2
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: Org2MSP

    # ID to load the MSP definition as
    ID: Org2MSP

    MSPDir: crypto-config/peerOrganizations/org2.example.com/msp

    AnchorPeers:
        # AnchorPeers defines the location of peers which can be used
        # for cross org gossip communication.  Note, this value is only
        # encoded in the genesis block in the Application section context
        - Host: peer0.org2.example.com
          Port: 7051
Run Code Online (Sandbox Code Playgroud)

在这里,我们用它的同行来定义我们的组织,并为我们的结构提供这些组织的加密材料的链接。所以在这个例子中,我们在文件顶部有 3 个组织 Orderer Organization 和 2 个其他 peerOrganizations,您可以注意到以下内容

Name: OrdererOrg
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/example.com/msp
Run Code Online (Sandbox Code Playgroud)

这是订购者组织的配置,我们向会员服务提供商提供 id,该框架处理所有加密操作的签名、验证、发布和链接,我们将其与该组织的加密材料位于我们的文件系统上的位置链接MSPDir.

和以下 peerOrganizations Org1 和 Org2 遵循相同的结构,除了它们必须包含在锚点中,允许您的组织点与其他组织点进行通信,这是与多个组织保持数据同步的主要点,因此我们必须定义以下部分中每个组织的锚点对等体

AnchorPeers:
        # AnchorPeers defines the location of peers which can be used
        # for cross org gossip communication.  Note, this value is only
        # encoded in the genesis block in the Application section context
        - Host: peer0.org1.example.com
          Port: 7051
Run Code Online (Sandbox Code Playgroud)

现在移动到文件中的另一个部分,即Orderer:它看起来像

Orderer: &OrdererDefaults

# Orderer Type: The orderer implementation to start
# Available types are "solo" and "kafka"
OrdererType: solo

Addresses:
    - orderer.example.com:7050

# Batch Timeout: The amount of time to wait before creating a batch
BatchTimeout: 2s

# Batch Size: Controls the number of messages batched into a block
BatchSize:

    # Max Message Count: The maximum number of messages to permit in a batch
    MaxMessageCount: 10

    # Absolute Max Bytes: The absolute maximum number of bytes allowed for
    # the serialized messages in a batch.
    AbsoluteMaxBytes: 99 MB

    # 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.
    PreferredMaxBytes: 512 KB

Kafka:
    # Brokers: A list of Kafka brokers to which the orderer connects
    # NOTE: Use IP:port notation
    Brokers:
        - 127.0.0.1:9092

# Organizations is the list of orgs which are defined as participants on
# the orderer side of the network
Organizations:
Run Code Online (Sandbox Code Playgroud)

如果您注意到Orderer: &OrdererDefaults它是保存以下设置的别名,因此我们可以在配置文件部分使用它,这将在本部分之后解释

    OrdererType: solo
Run Code Online (Sandbox Code Playgroud)

意味着我们使用适用于开发但不适用于生产的单独消息服务器,我们在生产环境中使用 kafka。

Addresses:
    - orderer.example.com:7050
Run Code Online (Sandbox Code Playgroud)

此处订购者的地址我们只有一个订购者,但在实际生产情况下,我们可以有多个订购者,因此您可以在此处提供它的地址

BatchSize:

    # Max Message Count: The maximum number of messages to permit in a batch
    MaxMessageCount: 10

    # Absolute Max Bytes: The absolute maximum number of bytes allowed for
    # the serialized messages in a batch.
    AbsoluteMaxBytes: 99 MB

    # 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.
    PreferredMaxBytes: 512 KB
Run Code Online (Sandbox Code Playgroud)

在本节中,我们定义何时创建新块,因此它取决于您的业务用例,因此您可以依赖创建新块的时间,即BatchTimeoutBatchSize,该块应保留多少事务,甚至是最大大小块仔细更改这些值以满足您的需要。

Kafka:# Brokers:订购者连接的 Kafka 经纪人列表 # 注意:使用 IP:端口符号 Brokers:- 127.0.0.1:9092

如果您使用 kafka,将使用此配置,并且在生产中您将拥有多个代理,因此请提供您的代理的 IP 地址。

最后是个人资料部分:

Profiles:

TwoOrgsOrdererGenesis:
    Capabilities:
        <<: *ChannelCapabilities
    Orderer:
        <<: *OrdererDefaults
        Organizations:
            - *OrdererOrg
        Capabilities:
            <<: *OrdererCapabilities
    Consortiums:
        SampleConsortium:
            Organizations:
                - *Org1
                - *Org2
TwoOrgsChannel:
    Consortium: SampleConsortium
    Application:
        <<: *ApplicationDefaults
        Organizations:
            - *Org1
            - *Org2
        Capabilities:
            <<: *ApplicationCapabilities
Run Code Online (Sandbox Code Playgroud)

本节是以良好可读的语法组合我们所有的配置,换句话说,本节将在您尝试创建创世块时执行,在第一节中,我们将提供创建创世块的配置。

  <<: *ChannelCapabilities
Run Code Online (Sandbox Code Playgroud)

表示导入ChannelCapabilities别名在本节中所指的设置。

<<: *OrdererDefaults
Run Code Online (Sandbox Code Playgroud)

这意味着导入所有加密材料OrdererDefaults作为本节中引用它的别名。

在已归档的联盟中,我们在这里指定此订购者将服务于哪些组织,因为一个订购者可以为多个组织提供服务

TwoOrgsChannel是我们的组织将要参加记住每个组织都可以加入一个以上的通道,所以我们必须提供通道的通道联盟,以及让渠道知道谁是我们的加盟机构服务。

希望这对你有帮助。