以fabric-samples/balance-transfer例子:

1. 具体流程

fabric/examples/e2e_cli目录下存有文件network_setup.sh用于一键部署环境并测试chaincode示例代码。其中包括两个部分,一个是利用generateArtifacts.sh脚本文件配置组织关系和颁发证书,另一个是docker-compose-cli.yaml用于根据配置启动集群并测试chaincode的示例代码。

2. generateArtifacts.sh脚本文件

包含三个函数:

  • generateCerts:使用cryptogen工具根据crypto-config.yaml来生成证书。
  • replacePrivateKey:将docker-compose-e2e-template.yaml文档中的ca私钥替换成具体的私钥。(本例中未使用)
  • generateChannelArtifacts:使用configtxgen工具根据configtx.yaml文件来生成orderer genesis blockchannel configuration transactionanchor peer update

crypto-config.yaml的具体内容如下:

# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:# ---------------------------------------------------------------------------# Orderer# ---------------------------------------------------------------------------- Name: OrdererDomain: example.com# ---------------------------------------------------------------------------# "Specs" - See PeerOrgs below for complete description# ---------------------------------------------------------------------------Specs:- Hostname: orderer
# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:# ---------------------------------------------------------------------------# Org1# ---------------------------------------------------------------------------- Name: Org1Domain: 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: Org2Domain: org2.example.comTemplate:Count: 2Users:Count: 1

configtx.yaml的具体内容如下:

################################################################################
#
#   Profile
#
#   - Different configuration profiles may be encoded here to be specified
#   as parameters to the configtxgen tool
#
################################################################################
Profiles:TwoOrgsOrdererGenesis:Orderer:<<: *OrdererDefaultsOrganizations:- *OrdererOrgConsortiums:SampleConsortium:Organizations:- *Org1- *Org2TwoOrgsChannel:Consortium: SampleConsortiumApplication:<<: *ApplicationDefaultsOrganizations:- *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 environmentName: OrdererOrg# ID to load the MSP definition asID: OrdererMSP# MSPDir is the filesystem path which contains the MSP configurationMSPDir: crypto-config/ordererOrganizations/example.com/msp- &Org1# DefaultOrg defines the organization which is used in the sampleconfig# of the fabric.git development environmentName: Org1MSP# ID to load the MSP definition asID: Org1MSPMSPDir: crypto-config/peerOrganizations/org1.example.com/mspAnchorPeers:# 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.comPort: 7051- &Org2# DefaultOrg defines the organization which is used in the sampleconfig# of the fabric.git development environmentName: Org2MSP# ID to load the MSP definition asID: Org2MSPMSPDir: crypto-config/peerOrganizations/org2.example.com/mspAnchorPeers:# 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.comPort: 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: soloAddresses:- orderer.example.com:7050# Batch Timeout: The amount of time to wait before creating a batchBatchTimeout: 2s# Batch Size: Controls the number of messages batched into a blockBatchSize:# Max Message Count: The maximum number of messages to permit in a batchMaxMessageCount: 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 KBKafka:# Brokers: A list of Kafka brokers to which the orderer connects# NOTE: Use IP:port notationBrokers:- 127.0.0.1:9092# Organizations is the list of orgs which are defined as participants on# the orderer side of the networkOrganizations:################################################################################
#
#   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 networkOrganizations:

3. docker-compose-cli.yaml文件

根据组织关系启动docker集群,并在cli容器中执行command命令运行./scripts/script.sh脚本文件。

./scripts/script.sh脚本包含以下函数:

  • createChannel:创建channel。
  • joinChannel:将每个peer节点加入channel。
  • updateAnchorPeers
  • installChaincode:部署chaincode。
  • instantiateChaincode:初始化chaincode,并设置背书策略。
  • chaincodeQuery
  • chaincodeInvoke

Hyperledger Fabric 1.0 实例简析 第一课 network_setup.sh分析相关推荐

  1. Hyperledger Fabric 1.0 实战开发系列 第一课 系统环境搭建

    有人说讲了那么多理论,总该来点实际动手的干货,嘿嘿,所以笔者开始写点实战,本人电脑为window10系统,故采用虚拟机virtualBox+Ubuntu来进行实战 1.下载virtualBox,可以到 ...

  2. Hyperledger Fabric 1.0 实战开发系列 第二课 Fabric环境搭建

    一.安装GO语言 下载最新版的go 打开Terminal,输入命令(以下命令都是以root管理员的角色进行的) su 输入密码:***** wget https://storage.googleapi ...

  3. Hyperledger Fabric 1.0 实战开发系列 第⑤课 fabric 证书解析

    通过cryptogen生成所有证书文件后,以peerOrgannizations的第一个组织树org1为例,每个目录和对应文件的功能如下: ca: 存放组织的根证书和对应的私钥文件,默认采用EC算法, ...

  4. Hyperledger Fabric 2.0 官方文档中文版 第6章 教程(下)

    Hyperledger Fabric 2.0 官方文档中文版 第6章 教程下 总目录 6.教程(下) 使用CouchDB 为什么使用CouchDB? 在Hyperledger Fabric中启用Cou ...

  5. Hyperledger Fabric 1.0 从零开始(十二)——fabric-sdk-java应用

    Hyperledger Fabric 1.0 从零开始(十)--智能合约(参阅:Hyperledger Fabric Chaincode for Operators--实操智能合约) Hyperled ...

  6. Hyperledger Fabric 2.0 官方文档中文版 第6章 教程(上)

    Hyperledger Fabric 2.0 官方文档中文版第6章 教程上 总目录 6.教程(上) 将智能合约部署到通道 启动网络 Logspout设置 打包智能合约 安装链码包 批准链码定义 将链码 ...

  7. Hyperledger Fabric 2.0 官方文档中文版 第3章 关键概念

    Hyperledger Fabric 2.0 官方文档中文版 第3章 关键概念 总目录 3.关键概念 引言 什么是区块链? 区块链为什么有用? 什么是Hyperledger Fabric? Hyper ...

  8. Hyperledger Fabric 2.0 官方文档中文版 第5章 开发应用程序

    Hyperledger Fabric 2.0 官方文档中文版 第5章 开发应用程序 总目录 5.开发应用程序 情景 PaperNet网络 介绍参与者 分析 商业票据生命周期 交易 账本 过程和数据设计 ...

  9. Hyperledger Fabric 1.0 从零开始(十二)——fabric-sdk-java应用【补充】

    在 Hyperledger Fabric 1.0 从零开始(十二)--fabric-sdk-java应用 中我已经把官方sdk具体改良办法,即使用办法发出来了,所有的类及文件都是完整的,在文章的结尾也 ...

最新文章

  1. Android OpenGL射线拾取手势旋转(二)
  2. springmvc 配置多个数据源,并动态切换
  3. java学习笔记(八)----包,jar文件
  4. math标准库函数功能汇总
  5. 介绍10个常用的Python内置函数,99.99%的人都在用!
  6. 高速公路 (Highway,CERC 2006,LA 3720)
  7. 最快15分钟,完成高精度AI模型定制开发
  8. Unity 5.x---00使用重力
  9. 电信网厅源码 php,基于php的电信基站接口调用代码实例
  10. 跳转指定位置(HTML)
  11. windows系统无法输入激活码
  12. 标准差(Standard Deviation)和标准误差(Standard Error)
  13. Android 10 电池图标修改
  14. 100 个网络基础知识普及,看完成半个网络高手!
  15. reflections歌词翻译_Reflections 歌词
  16. java中为什么要用json_Java中json的使用和解析
  17. 哈曼推出Savari MECWAVE:超低时延边缘计算平台提供交钥匙式互联服务
  18. Eureka学习笔记
  19. Automatic Software Repair: a Bibliography 自动软件修复概览(三)
  20. 2021陇剑杯部分wp

热门文章

  1. GridView实现自动编号
  2. 吴恩达 coursera AI 专项四第一课总结+作业答案
  3. 远程唤醒linux系统方法
  4. 简单易学的机器学习算法——神经网络之BP神经网络
  5. Softmax vs. SoftmaxWithLoss 推导过程
  6. 【编程】位(bit)、字节(byte)和字(word)的区别
  7. 科大星云诗社动态20210226
  8. 330+ 个机器学习模型/库探索工具!Papers With Code 重磅推出!
  9. Jupyter notebook入门教程(下)
  10. Python类与对象技巧(2):拓展子类属性