基于hyperledger-fabric的区块链教程之网络搭建(2)

我们继续讲网络拓扑结构
摘要由CSDN通过智能技术生成

我们继续讲网络拓扑结构
区块链网络拓扑图
上述图中,有一个基础网络,右边红色区域是后面要讲的动态新增的组织。

定义网络拓扑配置

首先新建一个工程目录,我们暂定名称为:basic-network。

组织结构配置

定义3个组织

  • 排序组织(orderer),挂接一个排序节点
  • 两个数据块组织(peer),分别挂接两个数据节点

crypto-config.yaml:

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------

# cryptogen读取文件生成如下结构:
# type OrgSpec struct {
   
#     Name          string       `yaml:"Name"`
#     Domain        string       `yaml:"Domain"`
#     EnableNodeOUs bool         `yaml:"EnableNodeOUs"`
#     CA            NodeSpec     `yaml:"CA"`
#     Template      NodeTemplate `yaml:"Template"`
#     Specs         []NodeSpec   `yaml:"Specs"`
#     Users         UsersSpec    `yaml:"Users"`
# }

OrdererOrgs:
  # ---------------------------------------------------------------------------
  # Orderer
  # ---------------------------------------------------------------------------
  - Name: Orderer
    Domain: example.com
    #设置了EnableNodeOUs,就在msp下生成config.yaml文件 
    EnableNodeOUs: true
    # ---------------------------------------------------------------------------
    # "Specs" - See PeerOrgs below for complete description
    # ---------------------------------------------------------------------------
    Specs:
      - Hostname: orderer

# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
  # ---------------------------------------------------------------------------
  # OrgRoot
  # ---------------------------------------------------------------------------
  - Name: OrgRoot
    Domain: orgroot.example.com
    EnableNodeOUs: true
    # ---------------------------------------------------------------------------
    # "Specs"
    # ---------------------------------------------------------------------------
    # Uncomment this section to enable the explicit definition of hosts in your
    # configuration.  Most users will want to use Template, below
    #
    # Specs is an array of Spec entries.  Each Spec entry consists of two fields:
    #   - Hostname:   (Required) The desired hostname, sans the domain.
    #   - CommonName: (Optional) Specifies the template or explicit override for
    #                 the CN.  By default, this is the template:
    #
    #                              "{
   {.Hostname}}.{
   {.Domain}}"
    #
    #                 which obtains its values from the Spec.Hostname and
    #                 Org.Domain, respectively.
    # ---------------------------------------------------------------------------
    # Specs:
    #   - Hostname: foo # implicitly "foo.org1.example.com"
    #     CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above
    #   - Hostname: bar
    #   - Hostname: baz
    # ---------------------------------------------------------------------------
    # "Template"
    # ---------------------------------------------------------------------------
    # Allows for the definition of 1 or more hosts that are created sequentially
    # from a template. By default, this looks like "peer%d" from 0 to Count-1.
    # You may override the number of nodes (Count), the starting index (Start)
    # or the template used to construct the name (Hostname).
    #
    # Note: Template and Specs are not mutually exclusive.  You may define both
    # sections and the aggregate nodes will be created for you.  Take care with
    # name collisions
    # ---------------------------------------------------------------------------
    Template:
      # OrgRoot组件下有两个节点,也即在域名:orgroot.example.com有两个节点:
      # peer0.orgroot.example.com 和 peer1.orgroot.example.com
      Count: 2
      # Start: 5
      # Hostname: {
   {.Prefix}}{
   {.Index}} # default
    # ---------------------------------------------------------------------------
    # "Users"
    # ---------------------------------------------------------------------------
    # Count: The number of user accounts _in addition_ to Admin
    # ---------------------------------------------------------------------------
    Users:
      Count: 1
  # ---------------------------------------------------------------------------
  # Org2: See "OrgRoot" for full specification
  # ---------------------------------------------------------------------------
  - Name: OrgMain
    Domain: orgmain.example.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1

定义组织证书材料配置

  • 定义排序节点使用的模式: solo、kafka以及raft,我们是目前采用solo模式
  • 定义数据节点组织的联盟
  • 定义数据节点下各个角色的权限
 # Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

---
################################################################################
#
#   Section: Organizations
#
#   - This section defines the different organizational identities which will
#   be referenced later in the configuration.
#
################################################################################
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

        # 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')"
            Writers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('OrdererMSP.admin')"

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

        # ID to load the MSP definition as
        ID: OrgRootMSP

        MSPDir: crypto-config/peerOrganizations/orgroot.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('OrgRootMSP.admin', 'OrgRootMSP.peer', 'OrgRootMSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('OrgRootMSP.admin', 'OrgRootMSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('OrgRootMSP.admin')"

        # leave this flag set to true.
        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.orgroot.example.com
              Port: 7051

    - &OrgMain
        # DefaultOrg defines the organization which is used in the sampleconfig
        # of the fabric.git development environment
        Name: OrgMainMS
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值