Skip to content

Commit

Permalink
Merge pull request #607 from hyperledger-labs/release-2.0
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
greatcyang committed Apr 4, 2020
2 parents 29d1bd7 + 21273c0 commit 525c50c
Show file tree
Hide file tree
Showing 17 changed files with 813 additions and 1,523 deletions.
371 changes: 99 additions & 272 deletions docs/source/CONTRIBUTING.rst

Large diffs are not rendered by default.

330 changes: 124 additions & 206 deletions docs/source/Fabric-FAQ.rst

Large diffs are not rendered by default.

78 changes: 31 additions & 47 deletions docs/source/commands/configtxgen.md
Original file line number Diff line number Diff line change
@@ -1,111 +1,95 @@
# configtxgen

The `configtxgen` command allows users to create and inspect channel config
related artifacts. The content of the generated artifacts is dictated by the
contents of `configtx.yaml`.
`configtxgen` 命令允许用户创建和查看通道配置相关构件。所生成的构件取决于 `configtx.yaml` 的内容。

## Syntax
## 语法

The `configtxgen` tool has no sub-commands, but supports flags which can be set
to accomplish a number of tasks.
`configtxgen` 工具没有子命令,但是支持标识(flag),通过设置标识可以完成不同的任务。

## configtxgen
```
Usage of configtxgen:
-asOrg string
Performs the config generation as a particular organization (by name), only including values in the write set that org (likely) has privilege to set
以特定组织(按名称)执行配置生成,仅包括组织(可能)有权设置的写集中的值。
-channelCreateTxBaseProfile string
Specifies a profile to consider as the orderer system channel current state to allow modification of non-application parameters during channel create tx generation. Only valid in conjunction with 'outputCreateChannelTx'.
指定要视为排序系统通道当前状态的轮廓(profile),以允许在通道创建交易生成期间修改非应用程序参数。仅在与 “outputCreateChannelTX” 结合时有效。
-channelID string
The channel ID to use in the configtx
配置交易中使用的通道 ID。
-configPath string
The path containing the configuration to use (if set)
包含所用的配置的路径。(如果设置的话)
-inspectBlock string
Prints the configuration contained in the block at the specified path
打印指定路径的区块中包含的配置。
-inspectChannelCreateTx string
Prints the configuration contained in the transaction at the specified path
打印指定路径的交易中包含的配置。
-outputAnchorPeersUpdate string
Creates an config update to update an anchor peer (works only with the default channel creation, and only for the first update)
创建一个更新锚节点的配置更新(仅在默认通道创建时有效,并仅用于第一次更新)。
-outputBlock string
The path to write the genesis block to (if set)
写入创世区块的路径。(如果设置的话)
-outputCreateChannelTx string
The path to write a channel creation configtx to (if set)
写入通道创建交易的路径。(如果设置的话)
-printOrg string
Prints the definition of an organization as JSON. (useful for adding an org to a channel manually)
JSON 方式打印组织的定义。(手动向通道中添加组织时很有用)
-profile string
The profile from configtx.yaml to use for generation.
configtx.yaml 中用于生成的轮廓。
-version
Show version information
显示版本信息。
```

## Usage
## 用法

### Output a genesis block
### 输出创世区块

Write a genesis block to `genesis_block.pb` for channel `orderer-system-channel`
for profile `SampleSingleMSPRaftV1_1`.
将通道 `orderer-system-channel` 和轮廓(Profile) `SampleSingleMSPRaftV1_1` 的创世区块写入 `genesis_block.pb`

```
configtxgen -outputBlock genesis_block.pb -profile SampleSingleMSPRaftV1_1 -channelID orderer-system-channel
```

### Output a channel creation tx
### 输出创建通道的交易

Write a channel creation transaction to `create_chan_tx.pb` for profile
`SampleSingleMSPChannelV1_1`.
将轮廓 `SampleSingleMSPChannelV1_1` 的通道创建交易写入 `create_chan_tx.pb`

```
configtxgen -outputCreateChannelTx create_chan_tx.pb -profile SampleSingleMSPChannelV1_1 -channelID application-channel-1
```

### Inspect a genesis block
### 查看创世区块

Print the contents of a genesis block named `genesis_block.pb` to the screen as
JSON.
将创世区块 `genesis_block.pb` 以 JSON 格式打印到屏幕上。

```
configtxgen -inspectBlock genesis_block.pb
```

### Inspect a channel creation tx
### 查看创建通道交易

Print the contents of a channel creation tx named `create_chan_tx.pb` to the
screen as JSON.
将通道创建交易 `create_chan_tx.pb` 以 JSON 的格式打印到屏幕上。

```
configtxgen -inspectChannelCreateTx create_chan_tx.pb
```

### Print an organization definition
### 打印组织定义

Construct an organization definition based on the parameters such as MSPDir
from `configtx.yaml` and print it as JSON to the screen. (This output is useful
for channel reconfiguration workflows, such as adding a member).
基于 `configtx.yaml` 的配置项(比如 MSPdir)来构建组织并以 JSON 格式打印到屏幕。(常用于创建通道时的重新配置,例如添加成员)

```
configtxgen -printOrg Org1
```

### Output anchor peer tx
### 输出锚节点交易

Output a configuration update transaction to `anchor_peer_tx.pb` which sets the
anchor peers for organization Org1 as defined in profile
SampleSingleMSPChannelV1_1 based on `configtx.yaml`.
将配置更新交易输出到 `anchor_peer_tx.pb`,就是将组织 Org1 的锚节点设置成 `configtx.yaml` 中轮廓 SampleSingleMSPChannelV1_1 所定义的。

```
configtxgen -outputAnchorPeersUpdate anchor_peer_tx.pb -profile SampleSingleMSPChannelV1_1 -asOrg Org1
```

## Configuration
## 配置

The `configtxgen` tool's output is largely controlled by the content of
`configtx.yaml`. This file is searched for at `FABRIC_CFG_PATH` and must be
present for `configtxgen` to operate.
`configtxgen` 工具的输出依赖于 `configtx.yaml``configtx.yaml` 可在 `FABRIC_CFG_PATH` 下找到,且在 `configtxgen` 执行时必须存在。

Refer to the sample `configtx.yaml` shipped with Fabric for all possible
configuration options. You may find this file in the `config` directory of
the release artifacts tar, or you may find it under the `sampleconfig` folder
if you are building from source.
这个配置文件可以被编辑,或者通过重写环境变量的方式修改一些单独的属性,例如 `CONFIGTX_ORDERER_ORDERERTYPE=kafka`


<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
102 changes: 39 additions & 63 deletions docs/source/commands/configtxlator.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# configtxlator

The `configtxlator` command allows users to translate between protobuf and JSON
versions of fabric data structures and create config updates. The command may
either start a REST server to expose its functions over HTTP or may be utilized
directly as a command line tool.
`configtxlator` 命令允许用户在 protobuf 和 JSON 版本的 fabric 数据结构之间进行转换,并创建配置更新。该命令可以启动 REST 服务器并通过 HTTP 公开,也可以直接用作命令行工具。

## Syntax
## 语法

The `configtxlator` tool has five sub-commands, as follows:
`configtxlator` 工具有五个子命令,如下:

* start
* proto_encode
Expand All @@ -19,139 +16,118 @@ The `configtxlator` tool has five sub-commands, as follows:
```
usage: configtxlator start [<flags>]
Start the configtxlator REST server
启动 configtxlator REST 服务。
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--hostname="0.0.0.0" The hostname or IP on which the REST server will listen
--port=7059 The port on which the REST server will listen
--CORS=CORS ... Allowable CORS domains, e.g. '*' or 'www.example.com'
(may be repeated).
--help 查看完整的帮助(可以尝试 --help-long 和 --help-man)。
--hostname="0.0.0.0" REST 服务器监听的主机名或者 IP。
--port=7059 REST 服务器监听的端口。
--CORS=CORS ... 允许跨域的域名, 例如 ‘*’ 或者 ‘www.example.com’ (可能是重复的)。
```


## configtxlator proto_encode
```
usage: configtxlator proto_encode --type=TYPE [<flags>]
Converts a JSON document to protobuf.
JSON 文档转换为 protobuf
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--type=TYPE The type of protobuf structure to encode to. For
example, 'common.Config'.
--input=/dev/stdin A file containing the JSON document.
--output=/dev/stdout A file to write the output to.
--help 查看完整的帮助(可以尝试 --help-long 和 --help-man)。
--type=TYPE 要将 protobuf 编码成的类型。例如‘common.Config’。
--input=/dev/stdin 包含 JSON 文档的文件。
--output=/dev/stdout 要将输出写入的文件。
```


## configtxlator proto_decode
```
usage: configtxlator proto_decode --type=TYPE [<flags>]
Converts a proto message to JSON.
proto 消息转换为 JSON
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--type=TYPE The type of protobuf structure to decode from. For
example, 'common.Config'.
--input=/dev/stdin A file containing the proto message.
--output=/dev/stdout A file to write the JSON document to.
--help 查看完整的帮助(可以尝试 --help-long 和 --help-man)。
--type=TYPE 要将 protobuf 解码成的类型。例如‘common.Config’。
--input=/dev/stdin 包含 proto 消息的文件。
--output=/dev/stdout 要将 JSON 文档写入的文件。
```


## configtxlator compute_update
```
usage: configtxlator compute_update --channel_id=CHANNEL_ID [<flags>]
Takes two marshaled common.Config messages and computes the config update which
transitions between the two.
比较两个封送(marshaled)的 common.Config 信息,并计算它们的更新。
Flags:
--help Show context-sensitive help (also try --help-long and
--help-man).
--original=ORIGINAL The original config message.
--updated=UPDATED The updated config message.
--channel_id=CHANNEL_ID The name of the channel for this update.
--output=/dev/stdout A file to write the JSON document to.
--help 查看完整的帮助(可以尝试 --help-long 和 --help-man)。
--original=ORIGINAL 原始配置信息。
--updated=UPDATED 更新的配置信息。
--channel_id=CHANNEL_ID 本次更新的通道名。
--output=/dev/stdout 要将 JSON 文档写入的文件。
```


## configtxlator version
```
usage: configtxlator version
Show version information
显示版本信息。
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--help 查看完整的帮助(可以尝试 --help-long 和 --help-man)。
```

## Examples
## 示例

### Decoding
### 解码

Decode a block named `fabric_block.pb` to JSON and print to stdout.
将一个名为 `fabric_block.pb` 的块解码为 JSON 并打印到标准输出。

```
configtxlator proto_decode --input fabric_block.pb --type common.Block
```

Alternatively, after starting the REST server, the following curl command
performs the same operation through the REST API.
或者,在启动 REST 服务器之后,使用下面的 curl 命令通过 REST API 执行相同的操作。

```
curl -X POST --data-binary @fabric_block.pb "${CONFIGTXLATOR_URL}/protolator/decode/common.Block"
```

### Encoding
### 编码

Convert a JSON document for a policy from stdin to a file named `policy.pb`.
将策略的 JSON 文档从标准输入转换为名为 `policy.pb` 的文件。

```
configtxlator proto_encode --type common.Policy --output policy.pb
```

Alternatively, after starting the REST server, the following curl command
performs the same operation through the REST API.
或者,在启动 REST 服务器之后,使用下面的 curl 命令通过 REST API 执行相同的操作。

```
curl -X POST --data-binary /dev/stdin "${CONFIGTXLATOR_URL}/protolator/encode/common.Policy" > policy.pb
```

### Pipelines

Compute a config update from `original_config.pb` and `modified_config.pb` and decode it to JSON to stdout.
`original_config.pb` `modified_config.pb` 计算配置更新,然后将其解码为 JSON,再将其打印到标准输出。

```
configtxlator compute_update --channel_id testchan --original original_config.pb --updated modified_config.pb | configtxlator proto_decode --type common.ConfigUpdate
```

Alternatively, after starting the REST server, the following curl commands
perform the same operations through the REST API.
或者,在启动 REST 服务器之后,使用下面的 curl 命令通过 REST API 执行相同的操作。

```
curl -X POST -F channel=testchan -F "original=@original_config.pb" -F "updated=@modified_config.pb" "${CONFIGTXLATOR_URL}/configtxlator/compute/update-from-configs" | curl -X POST --data-binary /dev/stdin "${CONFIGTXLATOR_URL}/protolator/encode/common.ConfigUpdate"
```

## Additional Notes
## 附加笔记

The tool name is a portmanteau of *configtx* and *translator* and is intended to
convey that the tool simply converts between different equivalent data
representations. It does not generate configuration. It does not submit or
retrieve configuration. It does not modify configuration itself, it simply
provides some bijective operations between different views of the configtx
format.
该工具名称是 *configtx**translator* 的组合,旨在表示该工具只是在不同的等效数据表示之间进行转换。它不生成配置。它不提交或检索配置。它不修改配置本身,只是在 configtx 格式的不同视图之间提供一些双射操作。

There is no configuration file `configtxlator` nor any authentication or
authorization facilities included for the REST server. Because `configtxlator`
does not have any access to data, key material, or other information which
might be considered sensitive, there is no risk to the owner of the server in
exposing it to other clients. However, because the data sent by a user to
the REST server might be confidential, the user should either trust the
administrator of the server, run a local instance, or operate via the CLI.
对于 REST 服务器,既没有配置文件 `configtxlator`,也没有包含任何身份验证或授权工具。因为 `configtxlator` 不能访问任何可能被认为敏感的数据、关键材料或其他信息,所以服务器的所有者将其暴露给其他客户端没有风险。但是,由于用户发送到 REST 服务器的数据可能是机密的,所以用户应该信任服务器的管理员、运行本地实例或者通过 CLI 进行操作。

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.

0 comments on commit 525c50c

Please sign in to comment.