成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

Fabric網(wǎng)絡(luò)環(huán)境啟動(dòng)過(guò)程詳解

_ivan / 2391人閱讀

摘要:更新錨節(jié)點(diǎn)部署。可以與網(wǎng)絡(luò)中的其他進(jìn)行通信,每個(gè)都在本地保留一份的副本。用來(lái)對(duì)交易進(jìn)行排序,是共識(shí)機(jī)制的重要組成部分。以該配置的配置下的配置為例表示的服務(wù)中的或者角色擁有發(fā)起交易的權(quán)限。

本文首發(fā)于深入淺出區(qū)塊鏈社區(qū)
原文鏈接:Fabric網(wǎng)絡(luò)環(huán)境啟動(dòng)過(guò)程詳解原文已更新,請(qǐng)讀者前往原文閱讀

這篇文章對(duì)fabric的網(wǎng)絡(luò)環(huán)境啟動(dòng)過(guò)程進(jìn)行講解,也就是我們上節(jié)講到的啟動(dòng)測(cè)試fabric網(wǎng)絡(luò)環(huán)境時(shí)運(yùn)行network_setup.sh這個(gè)文件的執(zhí)行流程

fabric網(wǎng)絡(luò)環(huán)境啟動(dòng)過(guò)程詳解

上一節(jié)我們講到 fabric網(wǎng)絡(luò)環(huán)境的啟動(dòng)測(cè)試,主要是使用 ./network_setup.sh up 這個(gè)命令,所以fabric網(wǎng)絡(luò)環(huán)境啟動(dòng)的重點(diǎn)就在network_setup.sh這個(gè)文件中。接下來(lái)我們就分析一下network_setup.sh這個(gè)文件
network_setup.sh其中包括兩個(gè)部分,一個(gè)是利用generateArtifacts.sh腳本文件配置組織關(guān)系和頒發(fā)證書(shū)、公/私鑰、通道證書(shū)等,另一個(gè)是docker-compose-cli.yaml用于根據(jù)配置啟動(dòng)集群并測(cè)試chaincode的示例代碼。下面是具體的流程圖介紹:

首先看下generateArtifacts.sh腳本文件,它包含三個(gè)函數(shù),分別是:

1.generateCerts:
該函數(shù)使用cryptogen工具根據(jù)crypto-config.yaml來(lái)生成公私鑰和證書(shū)信息等。

2.replacePrivateKey:
將docker-compose-e2e-template.yaml文檔中的ca私鑰替換成具體的私鑰。

3.generateChannelArtifacts:
使用configtxgen工具根據(jù)configtx.yaml文件來(lái)生成創(chuàng)世區(qū)塊和通道相關(guān)信息,更新錨節(jié)點(diǎn)。

接著是docker-compose-cli.yaml文件
docker-compose-cli.yaml文件根據(jù)組織關(guān)系啟動(dòng)docker集群,并在cli容器中執(zhí)行command命令運(yùn)行./scripts/script.sh腳本文件。 那./scripts/script.sh腳本具體做了什么呢?

1.createChannel:創(chuàng)建channel。
2. joinChannel:將每個(gè)peer節(jié)點(diǎn)加入channel。
3. updateAnchorPeers:更新錨節(jié)點(diǎn)
4.  installChaincode:部署chaincode。 
5. instantiateChaincode:初始化chaincode。
6. chaincodeQuery:chaincode查詢

另外docker-compose-cli.yaml這個(gè)文件還有一個(gè)配置項(xiàng)是需要注意的地方,那就是:

file:  base/docker-compose-base.yaml

這里的docker-compose-base.yaml其實(shí)就是Orderer和peer的基礎(chǔ)配置文件,包括指定端口等。

幾個(gè)重要的配置文件 1.crypto-config.yaml

基于crypto-config.yaml(此文件在../fabric/examples/e2e_cli中)生成公、私鑰和證書(shū)信息,并保存在crypto-config文件夾中。另外crypto-config.yaml還定義了組織成員以及組織下的peer節(jié)點(diǎn)個(gè)數(shù)。
crypto-config.yaml文件講解:
字段Name和Domain就是關(guān)于這個(gè)組織的名字和域名,這主要是用于生成證書(shū)的時(shí)候,證書(shū)內(nèi)會(huì)包含該信息。而Template.Count=2是說(shuō)我們要生成2套公私鑰和證書(shū),一套是peer0.org1的,還有一套是peer1.org1的(也就指定了org中存在peer0和peer1兩個(gè)節(jié)點(diǎn))。最后Users.Count=1是說(shuō)每個(gè)Template下面會(huì)有幾個(gè)普通User(注意,Admin是Admin,不包含在這個(gè)計(jì)數(shù)中),這里配置了1,也就是說(shuō)我們只需要一個(gè)普通用戶[email protected] 我們可以根據(jù)實(shí)際需要調(diào)整這個(gè)配置文件,增刪Org Users等。文件內(nèi)容如下:

  # ---------------------------------------------------------------------------
  # Orderer
  # ---------------------------------------------------------------------------
  - Name: Orderer
    Domain: example.com
    # ---------------------------------------------------------------------------
    # "Specs" - See PeerOrgs below for complete description
    # ---------------------------------------------------------------------------
    Specs:
      - Hostname: orderer
# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
  # ---------------------------------------------------------------------------
  # Org1
  # ---------------------------------------------------------------------------
  - Name: Org1
    Domain: org1.example.com
    # ---------------------------------------------------------------------------
    # "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:
      Count: 2
      # Start: 5
      # Hostname: {{.Prefix}}{{.Index}} # default
    # ---------------------------------------------------------------------------
    # "Users"
    # ---------------------------------------------------------------------------
    # Count: The number of user accounts _in addition_ to Admin
    # ---------------------------------------------------------------------------
    Users:
      Count: 1
  # ---------------------------------------------------------------------------
  # Org2: See "Org1" for full specification
  # ---------------------------------------------------------------------------
  - Name: Org2
    Domain: org2.example.com
    Template:
      Count: 2
    Users:
      Count: 1

注:
peer:
Fabric 網(wǎng)絡(luò)中的節(jié)點(diǎn),表現(xiàn)為一個(gè)運(yùn)行著的docker容器。可以與網(wǎng)絡(luò)中的其他peer進(jìn)行通信,每個(gè)peer都在本地保留一份ledger的副本。它是org下的組織成員。
org:
一個(gè)組織,它可以由一個(gè)或多個(gè)peer組成。
Orderer :
聯(lián)盟成員共享的中心化節(jié)點(diǎn)。用來(lái)對(duì)交易進(jìn)行排序,是 Fabric 共識(shí)機(jī)制的重要組成部分。

2.configtx.yaml

基于configtx.yaml(此文件在../fabric/examples/e2e_cli中)生成創(chuàng)世區(qū)塊和通道相關(guān)信息,并保存在channel-artifacts文件夾。還可以指定背書(shū)策略。
configtx.yaml文件講解:
1.官方提供的examples/e2e_cli/configtx.yaml這個(gè)文件里面配置了由2個(gè)Org參與的Orderer共識(shí)配置TwoOrgsOrdererGenesis,以及由2個(gè)Org參與的Channel配置:TwoOrgsChannel。
2.另外我們可以在此文件的Orderer部分設(shè)置共識(shí)的算法是Solo還是Kafka,以及共識(shí)時(shí)區(qū)塊大小,超時(shí)時(shí)間等,我們使用默認(rèn)值即可,不用更改。而Peer節(jié)點(diǎn)的配置包含了MSP的配置,錨節(jié)點(diǎn)的配置。如果我們有更多的Org,或者有更多的Channel,那么就可以根據(jù)模板進(jìn)行對(duì)應(yīng)的修改。
3.Policies配置也要特別注意,該配置項(xiàng)定義了不同角色的權(quán)限,Reader,Writer以及Admin分別對(duì)應(yīng)讀,寫(xiě),以及admin權(quán)限,讀權(quán)限角色只能從別的peer節(jié)點(diǎn)同步賬本而不能發(fā)起交易,只有writer定義項(xiàng)下的角色才擁有發(fā)起交易的也就是調(diào)用chaincode的invoke方法的權(quán)限(不一定都是invoke方案,只要涉及到chaincode中狀態(tài)修改的方法,都只有擁有writer權(quán)限或admin權(quán)限的角色才能調(diào)用)。以該配置的Organizations配置下的Org1配置為例,"OR("Org1MSP.admin", "Org1MSP.client")",表示org1的msp服務(wù)中的admin或者client角色擁有發(fā)起交易的權(quán)限。文件內(nèi)容如下:

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

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

    TwoOrgsOrdererGenesis:
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
    TwoOrgsChannel:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2

################################################################################
#
#   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

    - &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

################################################################################
#
#   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
    # 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: 98 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:

################################################################################
#
#   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:

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/24457.html

相關(guān)文章

  • 區(qū)塊鏈開(kāi)發(fā)中使用的最流行的編程語(yǔ)言

    摘要:我們目前正處于一個(gè)新興的區(qū)塊鏈開(kāi)發(fā)行業(yè)中。,一種在以太坊開(kāi)發(fā)人員中流行的新的簡(jiǎn)單編程語(yǔ)言,因?yàn)樗怯糜陂_(kāi)發(fā)以太坊智能合約的語(yǔ)言。它是全球至少萬(wàn)開(kāi)發(fā)人員使用的世界上最流行的編程語(yǔ)言之一。以太坊,主要是針對(duì)工程師使用進(jìn)行區(qū)塊鏈以太坊開(kāi)發(fā)的詳解。 我們目前正處于一個(gè)新興的區(qū)塊鏈開(kāi)發(fā)行業(yè)中。區(qū)塊鏈技術(shù)處于初期階段,然而這種顛覆性技術(shù)已經(jīng)成功地風(fēng)靡全球,并且最近經(jīng)歷了一場(chǎng)與眾不同的繁榮。由于許多...

    2shou 評(píng)論0 收藏0
  • Java開(kāi)發(fā)區(qū)塊鏈的三大sdk庫(kù)

    摘要:是企業(yè)與區(qū)塊鏈相遇的地方。的框架旨在成為開(kāi)發(fā)區(qū)塊鏈解決方案的支柱。以太坊,主要是針對(duì)工程師使用進(jìn)行區(qū)塊鏈以太坊開(kāi)發(fā)的詳解。 如果你想將區(qū)塊鏈合并到一個(gè)Java項(xiàng)目中,現(xiàn)在我們來(lái)看看就是這個(gè)細(xì)分領(lǐng)域中三個(gè)最大的OSS玩家。 好的伙計(jì)們,我們都聽(tīng)說(shuō)過(guò)比特幣,以太坊或其他加密貨幣,其中有一些時(shí)髦的名字圍繞著我們常見(jiàn)的新聞,但我們作為Java開(kāi)發(fā)人員知道如何輕松地與這些區(qū)塊鏈技術(shù)進(jìn)行交互嗎?以...

    iKcamp 評(píng)論0 收藏0
  • 基于ubuntu16.04部署IBM開(kāi)源區(qū)塊鏈項(xiàng)目-彈珠資產(chǎn)管理(Marbles)

    摘要:協(xié)議的細(xì)節(jié)由一個(gè)名為的處理。運(yùn)行下面的腳本來(lái)讓所有的事情都發(fā)生一兩分鐘后,命令提示符將返回運(yùn)行結(jié)果如下圖所示現(xiàn)在運(yùn)行該命令查看當(dāng)前正在運(yùn)行的容器。 showImg(https://segmentfault.com/img/bVbazHF?w=709&h=159); 前言 本教程基本上是對(duì)Marbles項(xiàng)目的翻譯過(guò)程. 如果英文比較好的話,建議根據(jù)官方操作說(shuō)明,一步步進(jìn)行環(huán)境部署。當(dāng)然你...

    voidking 評(píng)論0 收藏0
  • 聯(lián)盟鏈初識(shí)以及Fabric環(huán)境搭建流程

    摘要:本文首發(fā)于深入淺出區(qū)塊鏈社區(qū)原文鏈接聯(lián)盟鏈初識(shí)以及環(huán)境搭建流程原文已更新,請(qǐng)讀者前往原文閱讀這篇文章首先簡(jiǎn)單介紹了聯(lián)盟鏈?zhǔn)鞘裁?,再詳?xì)的介紹了環(huán)境搭建的整個(gè)流程。 本文首發(fā)于深入淺出區(qū)塊鏈社區(qū)原文鏈接:聯(lián)盟鏈初識(shí)以及Fabric環(huán)境搭建流程原文已更新,請(qǐng)讀者前往原文閱讀 這篇文章首先簡(jiǎn)單介紹了聯(lián)盟鏈?zhǔn)鞘裁矗僭敿?xì)的介紹了Fabric環(huán)境搭建的整個(gè)流程。 區(qū)塊鏈分類(lèi): 以參與方式分類(lèi),區(qū)...

    CoffeX 評(píng)論0 收藏0
  • Hyperledger Fabric(編寫(xiě)你的第一個(gè)應(yīng)用程序)

    摘要:一個(gè)更新提案,認(rèn)可,然后返回到應(yīng)用程序,然后將其發(fā)送給每個(gè)對(duì)等點(diǎn)的分類(lèi)帳我們對(duì)分類(lèi)賬的第一次更新將是創(chuàng)建一輛新車(chē),我們有一個(gè)單獨(dú)的程序我們將用它來(lái)進(jìn)行更新。 編寫(xiě)第一個(gè)應(yīng)用程序 如果你還不熟悉Fabric網(wǎng)絡(luò)的基本架構(gòu),則可能需要在繼續(xù)之前訪問(wèn)介紹和構(gòu)建你的第一個(gè)網(wǎng)絡(luò)文檔。 在本節(jié)中,我們將介紹一些示例程序,以了解Fabric應(yīng)用程序的工作原理,這些應(yīng)用程序(以及他們使用的智能合約) ...

    Hydrogen 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<