利用Hyperledger fabric-config库进行通道配置更新

本文介绍了如何使用fabric-config库来简化Hyperledger Fabric通道配置更新的过程,避免了手动JSON解析带来的繁琐和错误。fabric-config库提供了一个独立的库,支持生成配置包络,包括通道配置更新,并提供了丰富的API以安全地修改配置值。文章详细阐述了使用fabric-config进行配置更新的步骤,包括获取配置块、使用库进行更新、计算增量、签名和提交更新事务。
摘要由CSDN通过智能技术生成

介绍 (Introduction)

In this article, we introduce the fabric-config library and show how it can be used for channel configuration updates. Specifically, we will provide an example program that leverages the fabric-config library to make changes to block cutting parameters. You will find in this article explicit guidance on how to get started with the library and functions that you can include in your program so you can start using this library seamlessly in your next project.

在本文中,我们介绍了fabric-config库,并展示了如何将其用于通道配置更新。 具体来说,我们将提供一个示例程序,该程序利用fabric-config库更改块切割参数。 在本文中,您将找到有关如何开始使用可包含在程序中的库和函数的明确指导,以便可以在下一个项目中无缝使用该库。

通道配置概述 (Overview of channel configurations)

A Hyperledger Fabric network is made up of structures and processes that define how these structures interact with the blockchain network. In this context, structures include artifacts such as organizations, peers, identity credentials, ordering nodes, and certificate authorities among others.

Hyperledger Fabric网络由定义这些结构如何与区块链网络交互的结构和过程组成。 在这种情况下,结构包括工件,例如组织,对等方,身份凭证,订购节点和证书颁发机构等。

The data that identifies the structures and their corresponding processes (i.e. governing instructions for network interactions) are contained in channel configurations. These configurations are, in turn, found in blocks that have been committed to the ledger of a channel. Therefore, the process for modifying a channel configuration is referred to as a configuration update transaction. Concrete examples of channel configuration updates include some of the following common scenarios:

标识结构及其相应过程(即,用于网络交互的管理指令)的数据包含在通道配置中。 这些配置又可以在已提交给通道分类帐的块中找到。 因此,用于修改通道配置的过程称为配置更新事务。 通道配置更新的具体示例包括以下一些常见方案:

  • Updating the maximum number of transactions that should appear within a block.

    更新应该在一个区块中出现的最大事务数。
  • Updating the amount of time to wait for additional transactions after the first transaction arrives before cutting a block.

    在第一个交易到达之后,在切割区块之前,更新等待更多交易的时间。
  • Updating the Raft ordering service parameters.

    更新筏订购服务参数。
  • Updating the signature requirements for a block to be considered valid.

    更新被视为有效的块的签名要求。
  • Adding a new organization to an existing channel.

    将新组织添加到现有渠道。
  • Adding a new organization to the consortium.

    将新组织添加到联盟。

更新频道配置 (Updating channel configurations)

Until recently, the recommended approach for updating a channel configuration involved using the configtxlator and jq tools. The steps for using these tools when updating a channel configuration can be summarized as follows:

直到最近,使用configtxlatorjq工具进行更新通道配置的推荐方法。 在更新通道配置时使用这些工具的步骤可以概括如下:

1) Fetch the latest configuration block of a channel.

1)获取通道的最新配置块。

2) Decode the latest configuration block from protobuf format into JSON.

2)将最新的配置块从protobuf格式解码为JSON。

3) Remove unnecessary metadata from the JSON configuration block using jq.

3)使用jq从JSON配置块中删除不必要的元数据。

4) Create a copy of the JSON configuration block.

4)创建JSON配置块的副本。

5) Make the corresponding updates to the copied JSON configuration block (e.g. update the maximum number of transactions in a block).

5)对复制的JSON配置块进行相应的更新(例如,更新一个块中的最大事务数)。

6) Encode the JSON updated configuration block back to protobuf.

6)将JSON更新的配置块编码回protobuf。

7) Compute the difference between the two configuration protobufs (i.e. original configuration block and the updated configuration block). This results in a new config update protobuf which contains the delta.

7)计算两个配置协议(即原始配置块和更新后的配置块)之间的差异。 这将导致包含该增量的新配置更新协议。

8) Decode delta back into JSON.

8)将增量解码回JSON。

9) Add necessary header to JSON delta so it is wrapped in an envelope message using jq.

9)将必要的标头添加到JSON增量中,以便使用jq将其包装在信封消息中。

10) Encode JSON delta to protobuf.

10)将JSON增量编码为protobuf。

11) Sign the config update transaction.

11)签署配置更新事务。

12) Submit the config update transaction to the ordering service via a peer.

12)通过对等方将配置更新事务提交给订购服务。

Though the above approach works, it is quite tedious and error-prone. For instance, it is quite easy to forget to strip out the header (step 3) after decoding the latest configuration block or to add the header to the delta block (step 9). Also, step 5 is quite easy to mess up. While editing the JSON block either manually with a text editor [such as Visual Studio or Atom] or using jq, you could make the changes in the wrong section of the JSON document and/or introduce one or more typos. Also, while ideally, you should have a thorough understanding of the JSON schema before making any changes to the JSON block, the reality is that not everyone possesses this knowledge. Therefore, a different mechanism that is not error-prone and simplifies the process for updating a channel configuration is preferred. A much better approach would be one that allows you to use a type-safe and compiled language such as Go. In the next section, we introduce this new mechanism.

尽管上述方法可行,但它非常繁琐且容易出错。 例如,很容易忘记在解码最新的配置块后剥离标题(步骤3)或将标题添加到增量块(步骤9)。 而且,第5步很容易搞砸。 在使用文本编辑器(例如Visual Studio或Atom)或使用jq手动编辑JSON块时,可以在JSON文档的错误部分进行更改和/或引入一个或多个输入错误。 另外,理想情况下,在对JSON块进行任何更改之前,您应该对JSON模式有透彻的了解,但现实情况是,并不是每个人都拥有这一知识。 因此,优选不易出错并且简化用于更新信道配置的过程的不同机制。 一种更好的方法是允许您使用类型安全的 编译语言(例如Go)。 在下一节中,我们将介绍这种新机制。

It is also worth mentioning that the configtxlator tool should eventually be deprecated and later removed at some point in the future as consumers are encouraged to develop their own tooling utilizing the config update process detailed below. This is also another reason why you should start getting familiar with the newest mechanism for updating channel configurations.

还值得一提的是,由于鼓励消费者使用下面详细介绍的config update过程开发自己的工具,因此最终应弃用configtxlator工具,以后再将其删除。 这也是为什么您应该开始熟悉用于更新通道配置的最新机制的另一个原因。

Note: It is beyond the scope of this article to provide the low level details and instructions for using the configtxlator and jq tools. For complete details on this, see Updating a channel configur

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: hyperledger-fabric-linux-amd64-2.2.0.tar.gz 是一个开源的区块链平台Hyperledger Fabric的最新版本软件包,可以在Linux系统的AMD64处理器上运行。这个软件包包含了Hyperledger Fabric平台的所有核心组件和工具,如Peer、Ordering Service等,以及一些示例链码和应用程序。用户可以通过下载该软件包并按照相关文档进行安装和部署来使用Hyperledger Fabric平台搭建自己的区块链网络。 Hyperledger Fabric平台是一个开放且可扩展的企业级区块链解决方案,它提供了高度灵活的合约机制和身份管理机制,支持多个链码、多个共识算法等特性,能够满足广泛的区块链应用需求。同时,它还支持跨组织、跨区块链网络的交互,并提供了完备的监管和审计机制,帮助企业构建安全、透明、高效的区块链应用。 总之,从技术角度来看,hyperledger-fabric-linux-amd64-2.2.0.tar.gz是一个具有广泛应用前景的区块链平台的软件包,对于希望构建企业级区块链应用的开发者和企业来说,具有重要的意义和价值。 ### 回答2: Hyperledger Fabric是一个开源区块链平台,该平台由Linux Foundation主导,集成了智能合约、无状态认证、加密等多种功能,可以用于开发分布式应用程序。Hyperledger Fabric的最新版本是2.2.0,其中hyperledger-fabric-linux-amd64-2.2.0.tar.gz是针对Linux操作系统平台的二进制文件,可以用于安装和运行Hyperledger Fabric。该文件包含了Hyperledger Fabric的所有组件和依赖项,包括peer节点、orderer节点、CA节点、CouchDB等。在安装过程中,只需要解压该文件,并根据文档中的指引进行配置和启动即可。该版本的Hyperledger Fabric增强了智能合约的安全性和可扩展性,提高了性能和稳定性,同时新增了对隐私保护和多租户支持等特性的支持,更好地适用于企业级区块链应用场景。使用Hyperledger Fabric可以构建高效、安全、可靠的分布式应用程序,是企业级区块链开发的首选平台之一。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值