涛声依旧在 发表于 昨天 20:35

Fabric 2.4.9 单机摆设多节点网络(多通道---分片区块链网络)

要举行本教程的内容,请先完成 Fabric 网络根本环境的搭建,Fabric 网络根本环境要求:安装git、curl、vim、jq、docker、docker-compose、Node.js,克隆下载 fabric 源码,克隆下载 fabric-samples 源码、下载二进制文件和拉取镜像。搭建 Fabric 网络根本环境,参考我之前写的文章:Hyperledger Fabric 2.4.9 环境搭建和 Caliper 0.5.0 测试工具摆设教程(Ubuntu)-CSDN博客
这里搭建的 Fabric 网络,是一个有着5个分片的分片区块链网络,有着1个排序构造(包罗3个排序节点)和5个平凡的构造(每个构造都包罗2个对等节点,对应5个分片),网络拓扑如下所示(这里省略了排序节点):
https://i-blog.csdnimg.cn/direct/81e564e2997f4529b87808d199261a25.png
1. 天生干系的证书文件

在 ~/go/src/github.com/hyperledger 目次下新建 myfabric 文件夹并进入该文件夹:
mkdir myfabric && cd myfabric 该文件夹就是我们要摆设 Fabric 网络的根目次。
创建文件 crypto-config.yaml ,并用 gedit 软件打开:
touch crypto-config.yaml && gedit crypto-config.yaml 添加如下内容:

# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:
# ---------------------------------------------------------------------------
# Orderer
# ---------------------------------------------------------------------------
- Name: Orderer
    Domain: idy.com
    EnableNodeOUs: true

    Specs:
      - Hostname: orderer0
      - Hostname: orderer1
      - Hostname: orderer2

# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
# ---------------------------------------------------------------------------
# Org1
# ---------------------------------------------------------------------------
- Name: Org1
    Domain: org1.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2

    Users:
      Count: 1

# ---------------------------------------------------------------------------
# Org2
# ---------------------------------------------------------------------------
- Name: Org2
    Domain: org2.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1

# ---------------------------------------------------------------------------
# Org3
# ---------------------------------------------------------------------------
- Name: Org3
    Domain: org3.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1

# ---------------------------------------------------------------------------
# Org4
# ---------------------------------------------------------------------------
- Name: Org4
    Domain: org4.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1
      
# ---------------------------------------------------------------------------
# Org5
# ---------------------------------------------------------------------------
- Name: Org5
    Domain: org5.idy.com
    EnableNodeOUs: true
    Template:
      Count: 2
    Users:
      Count: 1 根据 crypto-config.yaml 天生干系的证书文件,天生的证书文件会在 ./crypto-config/ 文件夹下:
cryptogen generate --config=crypto-config.yaml 2. 天生干系的通道设置文件

创建文件 configtx.yaml ,并用 gedit 软件打开:
touch configtx.yaml && gedit configtx.yaml 添加如下内容:
# 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/idy.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')"

      # OrdererEndpoints:
      #   - orderer.example.com:7050

    - &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.idy.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('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org1MSP.admin', 'Org1MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org1MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org1MSP.peer')"

    - &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.idy.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('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org2MSP.admin', 'Org2MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org2MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org2MSP.peer')"
   
    - &Org3
      # DefaultOrg defines the organization which is used in the sampleconfig
      # of the fabric.git development environment
      Name: Org3MSP

      # ID to load the MSP definition as
      ID: Org3MSP

      MSPDir: crypto-config/peerOrganizations/org3.idy.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('Org3MSP.admin', 'Org3MSP.peer', 'Org3MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org3MSP.admin', 'Org3MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org3MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org3MSP.peer')"
      
    - &Org4
      # DefaultOrg defines the organization which is used in the sampleconfig
      # of the fabric.git development environment
      Name: Org4MSP

      # ID to load the MSP definition as
      ID: Org4MSP

      MSPDir: crypto-config/peerOrganizations/org4.idy.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('Org4MSP.admin', 'Org4MSP.peer', 'Org4MSP.client')"
            Writers:
                Type: Signature
                Rule: "OR('Org4MSP.admin', 'Org4MSP.client')"
            Admins:
                Type: Signature
                Rule: "OR('Org4MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org4MSP.peer')"
               
    - &Org5
      # DefaultOrg defines the organization which is used in the sampleconfig
      # of the fabric.git development environment
      Name: Org5MSP

      # ID to load the MSP definition as
      ID: Org5MSP

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

################################################################################
#
#   SECTION: Capabilities
#
#   - This section defines the capabilities of fabric network. This is a new
#   concept as of v1.1.0 and should not be utilized in mixed networks with
#   v1.0.x peers and orderers.Capabilities define features which must be
#   present in a fabric binary for that binary to safely participate in the
#   fabric network.For instance, if a new MSP type is added, newer binaries
#   might recognize and validate the signatures from this type, while older
#   binaries without this support would be unable to validate those
#   transactions.This could lead to different versions of the fabric binaries
#   having different world states.Instead, defining a capability for a channel
#   informs those binaries without this capability that they must cease
#   processing transactions until they have been upgraded.For v1.0.x if any
#   capabilities are defined (including a map with all capabilities turned off)
#   then the v1.0.x peer will deliberately crash.
#
################################################################################
Capabilities:
    # Channel capabilities apply to both the orderers and the peers and must be
    # supported by both.
    # Set the value of the capability to true to require it.
    Channel: &ChannelCapabilities
      # V2_0 capability ensures that orderers and peers behave according
      # to v2.0 channel capabilities. Orderers and peers from
      # prior releases would behave in an incompatible way, and are therefore
      # not able to participate in channels at v2.0 capability.
      # Prior to enabling V2.0 channel capabilities, ensure that all
      # orderers and peers on a channel are at v2.0.0 or later.
      V2_0: true

    # Orderer capabilities apply only to the orderers, and may be safely
    # used with prior release peers.
    # Set the value of the capability to true to require it.
    Orderer: &OrdererCapabilities
      # V2_0 orderer capability ensures that orderers behave according
      # to v2.0 orderer capabilities. Orderers from
      # prior releases would behave in an incompatible way, and are therefore
      # not able to participate in channels at v2.0 orderer capability.
      # Prior to enabling V2.0 orderer capabilities, ensure that all
      # orderers on channel are at v2.0.0 or later.
      V2_0: true

    # Application capabilities apply only to the peer network, and may be safely
    # used with prior release orderers.
    # Set the value of the capability to true to require it.
    Application: &ApplicationCapabilities
      # V2_0 application capability ensures that peers behave according
      # to v2.0 application capabilities. Peers from
      # prior releases would behave in an incompatible way, and are therefore
      # not able to participate in channels at v2.0 application capability.
      # Prior to enabling V2.0 application capabilities, ensure that all
      # peers on channel are at v2.0.0 or later.
      V2_0: true

################################################################################
#
#   SECTION: Application
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network
    Organizations:

    # Policies defines the set of policies at this level of the config tree
    # For Application policies, their canonical path is
    #   /Channel/Application/<PolicyName>
    Policies:
      Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
      Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
      Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
      LifecycleEndorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"
      Endorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"

    Capabilities:
      <<: *ApplicationCapabilities
################################################################################
#
#   SECTION: Orderer
#
#   - This section defines the values to encode into a config transaction or
#   genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults

    # Orderer Type: The orderer implementation to start
    OrdererType: etcdraft
    # Addresses used to be the list of orderer addresses that clients and peers
    # could connect to.However, this does not allow clients to associate orderer
    # addresses and orderer organizations which can be useful for things such
    # as TLS validation.The preferred way to specify orderer addresses is now
    # to include the OrdererEndpoints item in your org definition
    Addresses:
      - orderer0.idy.com:7050
      - orderer1.idy.com:8050
      - orderer2.idy.com:9050

    EtcdRaft:
      Consenters:
      - Host: orderer0.idy.com
          Port: 7050
          ClientTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer0.idy.com/tls/server.crt
          ServerTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer0.idy.com/tls/server.crt
         
      - Host: orderer1.idy.com
          Port: 8050
          ClientTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer1.idy.com/tls/server.crt
          ServerTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer1.idy.com/tls/server.crt
         
      - Host: orderer2.idy.com
          Port: 9050
          ClientTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer2.idy.com/tls/server.crt
          ServerTLSCert: crypto-config/ordererOrganizations/idy.com/orderers/orderer2.idy.com/tls/server.crt
         
    # 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

    # Organizations is the list of orgs which are defined as participants on
    # the orderer side of the network
    Organizations:

    # Policies defines the set of policies at this level of the config tree
    # For Orderer policies, their canonical path is
    #   /Channel/Orderer/<PolicyName>
    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"

################################################################################
#
#   CHANNEL
#
#   This section defines the values to encode into a config transaction or
#   genesis block for channel related parameters.
#
################################################################################
Channel: &ChannelDefaults
    # Policies defines the set of policies at this level of the config tree
    # For Channel policies, their canonical path is
    #   /Channel/<PolicyName>
    Policies:
      # Who may invoke the 'Deliver' API
      Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
      # Who may invoke the 'Broadcast' API
      Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
      # By default, who may modify elements at this config level
      Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"

    # Capabilities describes the channel level capabilities, see the
    # dedicated Capabilities section elsewhere in this file for a full
    # description
    Capabilities:
      <<: *ChannelCapabilities

################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles:

    FiveOrgsOrdererGenesis:
      <<: *ChannelDefaults
      Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
      Consortiums:
            SampleConsortium:
                Organizations:
                  - *Org1
                  - *Org2
                  - *Org3
                  - *Org4
                  - *Org5

    shard1Channel:
      Consortium: SampleConsortium
      <<: *ChannelDefaults
      Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
            Capabilities:
                <<: *ApplicationCapabilities
   
    shard2Channel:
      Consortium: SampleConsortium
      <<: *ChannelDefaults
      Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org2
            Capabilities:
                <<: *ApplicationCapabilities
               
    shard3Channel:
      Consortium: SampleConsortium
      <<: *ChannelDefaults
      Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org3
            Capabilities:
                <<: *ApplicationCapabilities   
               
    shard4Channel:
      Consortium: SampleConsortium
      <<: *ChannelDefaults
      Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org4
            Capabilities:
                <<: *ApplicationCapabilities
               
    shard5Channel:
      Consortium: SampleConsortium
      <<: *ChannelDefaults
      Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org5
            Capabilities:
                <<: *ApplicationCapabilities 天生创世区块文件:
configtxgen -profile FiveOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block -channelID system-channel https://i-blog.csdnimg.cn/direct/42e1f5c7530e4afaa6062d95b535cc13.png
分别天生5个分片的通道文件:
configtxgen -profile shard1Channel -outputCreateChannelTx ./channel-artifacts/shard1.tx -channelID shard1
configtxgen -profile shard2Channel -outputCreateChannelTx ./channel-artifacts/shard2.tx -channelID shard2
configtxgen -profile shard3Channel -outputCreateChannelTx ./channel-artifacts/shard3.tx -channelID shard3
configtxgen -profile shard4Channel -outputCreateChannelTx ./channel-artifacts/shard4.tx -channelID shard4
configtxgen -profile shard5Channel -outputCreateChannelTx ./channel-artifacts/shard5.tx -channelID shard5 https://i-blog.csdnimg.cn/direct/113c72fa91204934a50069bc269b4c8c.png
3. 天生docker-compose.yaml的启动文件

创建文件 docker-compose.yaml ,并用 gedit 软件打开:
touch docker-compose.yaml && gedit docker-compose.yaml version: '2.4'

volumes:
orderer0.idy.com:
orderer1.idy.com:
orderer2.idy.com:
peer0.org1.idy.com:
peer1.org1.idy.com:
peer0.org2.idy.com:
peer1.org2.idy.com:
peer0.org3.idy.com:
peer1.org3.idy.com:
peer0.org4.idy.com:
peer1.org4.idy.com:
peer0.org5.idy.com:
peer1.org5.idy.com:

networks:
test:
    name: Fabric_Sharding

services:

orderer0.idy.com:
    container_name: orderer0.idy.com
    image: hyperledger/fabric-orderer:latest
    labels:
      service: hyperledger-fabric
    environment:
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_LISTENPORT=7050
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      # enabled TLS
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=
      - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_CLUSTER_ROOTCAS=
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_CHANNELPARTICIPATION_ENABLED=true
      - ORDERER_ADMIN_TLS_ENABLED=true
      - ORDERER_ADMIN_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_ADMIN_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_ADMIN_TLS_ROOTCAS=
      - ORDERER_ADMIN_TLS_CLIENTROOTCAS=
      - ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: orderer
    volumes:
      - ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp:/var/hyperledger/orderer/msp
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer0.idy.com/tls:/var/hyperledger/orderer/tls
    ports:
      - 7050:7050
      - 7053:7053
    networks:
      - test

orderer1.idy.com:
    container_name: orderer1.idy.com
    image: hyperledger/fabric-orderer:latest
    labels:
      service: hyperledger-fabric
    environment:
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_LISTENPORT=8050
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      # enabled TLS
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=
      - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_CLUSTER_ROOTCAS=
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_CHANNELPARTICIPATION_ENABLED=true
      - ORDERER_ADMIN_TLS_ENABLED=true
      - ORDERER_ADMIN_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_ADMIN_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_ADMIN_TLS_ROOTCAS=
      - ORDERER_ADMIN_TLS_CLIENTROOTCAS=
      - ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: orderer
    volumes:
      - ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer1.idy.com/msp:/var/hyperledger/orderer/msp
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer1.idy.com/tls:/var/hyperledger/orderer/tls
    ports:
      - 8050:8050
      - 7054:7053
    networks:
      - test

orderer2.idy.com:
    container_name: orderer2.idy.com
    image: hyperledger/fabric-orderer:latest
    labels:
      service: hyperledger-fabric
    environment:
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_LISTENPORT=9050
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      # enabled TLS
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=
      - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_CLUSTER_ROOTCAS=
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
      - ORDERER_CHANNELPARTICIPATION_ENABLED=true
      - ORDERER_ADMIN_TLS_ENABLED=true
      - ORDERER_ADMIN_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_ADMIN_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_ADMIN_TLS_ROOTCAS=
      - ORDERER_ADMIN_TLS_CLIENTROOTCAS=
      - ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric
    command: orderer
    volumes:
      - ./channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer2.idy.com/msp:/var/hyperledger/orderer/msp
      - ./crypto-config/ordererOrganizations/idy.com/orderers/orderer2.idy.com/tls:/var/hyperledger/orderer/tls
    ports:
      - 9050:9050
      - 7055:7053
    networks:
      - test

peer0.org1.idy.com:
    container_name: peer0.org1.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org1.idy.com
      - CORE_PEER_ADDRESS=peer0.org1.idy.com:7051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:7051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org1.idy.com:7052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.idy.com:8051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.idy.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 7051:7051
    networks:
      - test

peer1.org1.idy.com:
    container_name: peer1.org1.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org1.idy.com
      - CORE_PEER_ADDRESS=peer1.org1.idy.com:8051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:8051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org1.idy.com:8052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:8052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.idy.com:7051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.idy.com:8051
      - CORE_PEER_LOCALMSPID=Org1MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org1.idy.com/peers/peer1.org1.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org1.idy.com/peers/peer1.org1.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 8051:8051
    networks:
      - test

peer0.org2.idy.com:
    container_name: peer0.org2.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org2.idy.com
      - CORE_PEER_ADDRESS=peer0.org2.idy.com:9051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:9051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org2.idy.com:9052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:9052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.idy.com:10051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.idy.com:9051
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 9051:9051
    networks:
      - test

peer1.org2.idy.com:
    container_name: peer1.org2.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org2.idy.com
      - CORE_PEER_ADDRESS=peer1.org2.idy.com:10051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:10051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org2.idy.com:10052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:10052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.idy.com:9051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.idy.com:10051
      - CORE_PEER_LOCALMSPID=Org2MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org2.idy.com/peers/peer1.org2.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org2.idy.com/peers/peer1.org2.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 10051:10051
    networks:
      - test

peer0.org3.idy.com:
    container_name: peer0.org3.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org3.idy.com
      - CORE_PEER_ADDRESS=peer0.org3.idy.com:11051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:11051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org3.idy.com:11052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:11052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org3.idy.com:12051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.idy.com:11051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 11051:11051
    networks:
      - test

peer1.org3.idy.com:
    container_name: peer1.org3.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org3.idy.com
      - CORE_PEER_ADDRESS=peer1.org3.idy.com:12051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:12051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org3.idy.com:12052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:12052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.idy.com:11051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org3.idy.com:12051
      - CORE_PEER_LOCALMSPID=Org3MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org3.idy.com/peers/peer1.org3.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org3.idy.com/peers/peer1.org3.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 12051:12051
    networks:
      - test

peer0.org4.idy.com:
    container_name: peer0.org4.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org4.idy.com
      - CORE_PEER_ADDRESS=peer0.org4.idy.com:13051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:13051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org4.idy.com:13052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:13052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org4.idy.com:14051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org4.idy.com:13051
      - CORE_PEER_LOCALMSPID=Org4MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 13051:13051
    networks:
      - test

peer1.org4.idy.com:
    container_name: peer1.org4.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org4.idy.com
      - CORE_PEER_ADDRESS=peer1.org4.idy.com:14051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:14051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org4.idy.com:14052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:14052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org4.idy.com:13051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org4.idy.com:14051
      - CORE_PEER_LOCALMSPID=Org4MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org4.idy.com/peers/peer1.org4.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org4.idy.com/peers/peer1.org4.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 14051:14051
    networks:
      - test

peer0.org5.idy.com:
    container_name: peer0.org5.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer0.org5.idy.com
      - CORE_PEER_ADDRESS=peer0.org5.idy.com:15051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:15051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org5.idy.com:15052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:15052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org5.idy.com:16051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org5.idy.com:15051
      - CORE_PEER_LOCALMSPID=Org5MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 15051:15051
    networks:
      - test

peer1.org5.idy.com:
    container_name: peer1.org5.idy.com
    image: hyperledger/fabric-peer:latest
    labels:
      service: hyperledger-fabric
    environment:
      #Generic peer variables
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=Fabric_Sharding
      - FABRIC_LOGGING_SPEC=INFO
      #- FABRIC_LOGGING_SPEC=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
      # Peer specific variabes
      - CORE_PEER_ID=peer1.org5.idy.com
      - CORE_PEER_ADDRESS=peer1.org5.idy.com:16051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:16051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org5.idy.com:16052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:16052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org5.idy.com:15051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org5.idy.com:16051
      - CORE_PEER_LOCALMSPID=Org5MSP
    volumes:
      - /var/run/docker.sock:/host/var/run/docker.sock
      - ./crypto-config/peerOrganizations/org5.idy.com/peers/peer1.org5.idy.com/msp:/etc/hyperledger/fabric/msp
      - ./crypto-config/peerOrganizations/org5.idy.com/peers/peer1.org5.idy.com/tls:/etc/hyperledger/fabric/tls
      - /var/run/:/host/var/run/
      - ./:/etc/hyperledger/channel/
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    ports:
      - 16051:16051
    networks:
      - test

cli1:
    container_name: cli1
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli1
      - CORE_PEER_ADDRESS=peer0.org1.idy.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/users/Admin@org1.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

cli2:
    container_name: cli2
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli2
      - CORE_PEER_ADDRESS=peer0.org2.idy.com:9051
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.idy.com/peers/peer0.org2.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.idy.com/users/Admin@org2.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

cli3:
    container_name: cli3
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli3
      - CORE_PEER_ADDRESS=peer0.org3.idy.com:11051
      - CORE_PEER_LOCALMSPID=Org3MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.idy.com/peers/peer0.org3.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org3.idy.com/users/Admin@org3.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

cli4:
    container_name: cli4
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli4
      - CORE_PEER_ADDRESS=peer0.org4.idy.com:13051
      - CORE_PEER_LOCALMSPID=Org4MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org4.idy.com/peers/peer0.org4.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org4.idy.com/users/Admin@org4.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test

cli5:
    container_name: cli5
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli5
      - CORE_PEER_ADDRESS=peer0.org5.idy.com:15051
      - CORE_PEER_LOCALMSPID=Org5MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.idy.com/peers/peer0.org5.idy.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org5.idy.com/users/Admin@org5.idy.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./chaincode/go/:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    networks:
      - test 在当前的目次下实行如下下令启动网络:
docker-compose up -d 检察节点状态:
docker ps -a 如果想要关闭网络,实行如下下令:
docker-compose down
docker volume prune 4. 通道干系设置利用

进入容器 cli1 :
docker exec -it cli1 bash 创建通道,天生通道文件:
peer channel create -o orderer0.idy.com:7050 -c shard1 -f ./channel-artifacts/shard1.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem https://i-blog.csdnimg.cn/direct/c202080cd83c41179116d1a5b290ed43.png
 检察天生的 shard1.block 通道文件:
ls https://i-blog.csdnimg.cn/direct/ee4503cfdc754300a1bbf80a6170b645.png
到场通道:
peer channel join -b shard1.block https://i-blog.csdnimg.cn/direct/33a2ce45bc4f4ba8a80df6c54557e879.png
退出容器 cli1 :
exit https://i-blog.csdnimg.cn/direct/6dda23ea0bed427cbc7c8ba125374188.png
然后分别进入 cli2/3/4/5 容器中,重复上面 cli1 中的利用(创建通道,到场通道)。
5. 链码调用

由于还未编写链码,以是先复制测试网络的链码文件,将 fabric-samples/chaincode/sacc/ 文件夹下的 sacc.go 文件复制到当前目次的 ./chaincode/go/ 目次下:
sudo cp ../fabric/scripts/fabric-samples/chaincode/sacc/sacc.go ./chaincode/go/ 将 fabric-samples/chaincode/sacc/ 目次下的 go.mod 文件和 go.sum 文件复制到 ~ 用户主目次下,然后利用 gedit 下令打开 go.mod 文件:
cp ../fabric/scripts/fabric-samples/chaincode/sacc/go.mod ~/
cp ../fabric/scripts/fabric-samples/chaincode/sacc/go.sum ~/
gedit ~/go.mod 只修改 go.mod 文件,将 module 修改为: github.com/hyperledger/fabric-cluster/chaincode/go ,然后将 go 的版本修改为: go 1.18 , go.mod 文件的内容如下:
module github.com/hyperledger/fabric-cluster/chaincode/go

go 1.18

require (
        github.com/hyperledger/fabric-chaincode-go v0.0.0-20190823162523-04390e015b85
        github.com/hyperledger/fabric-protos-go v0.0.0-20190821214336-621b908d5022
) 将修改后的文件复制到容器 cli1 中:
docker cp ~/go.mod cli1:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go
docker cp ~/go.sum cli1:/opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go 进入容器 cli1 ,进入链码文件:
docker exec -it cli1 bash
cd /opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go/ 设置署理并下载干系依赖:
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=on
go mod tidy
go mod vendor https://i-blog.csdnimg.cn/direct/f0453e3fa5044cfda282726bcdf69a9f.png
回到工作目次,链码打包并安装:
cd /opt/gopath/src/github.com/hyperledger/fabric/peer
peer lifecycle chaincode package sacc.tar.gz --path /opt/gopath/src/github.com/hyperledger/fabric-cluster/chaincode/go/ --label sacc_1
peer lifecycle chaincode install sacc.tar.gz https://i-blog.csdnimg.cn/direct/0da558593d0b44f2a5d68181fdb4e834.png
上图中末了一行是 package-id ,在构造允许中必要用到,如果忘了,也有查询下令:
peer lifecycle chaincode queryinstalled 授权允许链码:
peer lifecycle chaincode approveformyorg --channelID shard1 --name sacc --version 1.0 --init-required --package-id sacc_1:2975ee7870d40463a45052f874b4d13f11884d405b087d1296e217db3657132c --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem 留意,记得将 pakage-id ,更换成本身电脑上天生的。
允许乐成:
https://i-blog.csdnimg.cn/direct/e11d876d55bd487781a40ef511b7e8e9.png
检察允许状态:
peer lifecycle chaincode checkcommitreadiness --channelID shard1 --name sacc --version 1.0 --init-required --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem --output json https://i-blog.csdnimg.cn/direct/e0256209e1994c3587553c02a06506ca.png
链码提交:
peer lifecycle chaincode commit -o orderer1.idy.com:8050 --channelID shard1 --name sacc --version 1.0 --init-required --sequence 1 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer1.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem --peerAddresses peer0.org1.idy.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/ca.crt https://i-blog.csdnimg.cn/direct/dc09daf6fcef4d8b807d06af399195fd.png
链码调用,初始化:
peer chaincode invoke -o orderer2.idy.com:9050 --isInit --ordererTLSHostnameOverride orderer2.idy.com --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer2.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem -C shard1 -n sacc --peerAddresses peer0.org1.idy.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/ca.crt -c '{"Args":["IDY","100"]}' https://i-blog.csdnimg.cn/direct/ab40f678217041b1baadcbe4b5678b11.png
查询利用:
peer chaincode query -C shard1 -n sacc -c '{"Args":["query","IDY"]}' https://i-blog.csdnimg.cn/direct/6de086d175e34fb882a5292265383804.png
修改利用:
peer chaincode invoke -o orderer0.idy.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/idy.com/orderers/orderer0.idy.com/msp/tlscacerts/tlsca.idy.com-cert.pem -C shard1 -n sacc --peerAddresses peer0.org1.idy.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.idy.com/peers/peer0.org1.idy.com/tls/ca.crt -c '{"Args":["set","IDY","99"]}' https://i-blog.csdnimg.cn/direct/d18b05eb8c784098b31ed9094301c6c8.png
查询修改后的结果:
peer chaincode query -C shard1 -n sacc -c '{"Args":["query","IDY"]}' https://i-blog.csdnimg.cn/direct/35d0c003730540acb12badc0a63c048e.png
在容器 cli1 中的测试到此竣事。
退出容器 cli1 ,将容器 cli1 中的链码包分别复制到其他容器 cli2/3/4/5 中,以 cli2 为例:
exit
docker cp cli1:/opt/gopath/src/github.com/hyperledger/fabric/peer/sacc.tar.gz ./
docker cp sacc.tar.gz cli2:/opt/gopath/src/github.com/hyperledger/fabric/peer 分别进入容器 cli2/3/4/5 ,重复上面目面目器 cli1 中的利用举行测试(链码安装、允许、提交、调用、查询和修改)。
竣事!!!

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: Fabric 2.4.9 单机摆设多节点网络(多通道---分片区块链网络)