主题
fabric-x-sdk · 快速开始
本仓库无独立 server;"运行"等价于运行 example/endorser 或集成测试。
Makefile target
来源:Makefile。
| target | 行号 | 用途 |
|---|---|---|
checks | 2-5 | gofmt、go vet、addlicense |
unit-tests | 8-9 | 短模式单元测试 |
init-x | 12-14 | 生成 crypto + genesis block |
clean-x | 17-18 | 清空 crypto |
start-x | 21-42 | 启动 Fabric-X test committer + 创建 namespace |
test-x | 45-46 | 跑 TestFabricXCommitter 集成测试 |
stop-x | 49-50 | 停 committer |
start-fablo | 53-54 | 启 fablo 网络 |
stop-fablo | 57-58 | 停 fablo |
test-fablo | 61-62 | 跑 TestFablo 测试 |
clean-fablo | 65-67 | 清 fablo |
启 Fabric-X test committer
来源:Makefile:21-42。
sh
make init-x # 生成 crypto + genesis
make start-x # 启动 committer + namespace
make test-x # 跑 TestFabricXCommitter
make stop-x
make clean-x镜像与端口(Makefile:22-39):
| 项 | 值 |
|---|---|
| 镜像 | docker.io/hyperledger/fabric-x-committer-test-node:0.1.9 |
| 端口 | 4001 2110 2114 2117 7001 7050 5433 |
注入到容器的 env:
SC_SIDECAR_ORDERER_IDENTITY_MSP_DIRSC_SIDECAR_ORDERER_IDENTITY_MSP_IDSC_SIDECAR_ORDERER_CHANNEL_IDSC_SIDECAR_ORDERER_SIGNED_ENVELOPESSC_QUERY_SERVICE_SERVER_ENDPOINTSC_ORDERER_BLOCK_SIZE
启 fablo(另一种网络)
来源:Makefile:53-67。
sh
make start-fablo
make test-fablo
make stop-fablo
make clean-fablofablo 网络位于 testdata/fablo/,由 ./fablo up / ./fablo prune 驱动(Makefile:54, 58, 66)。
example/endorser
来源:example/endorser/README.md、example/endorser/cmd/endorser/main.go。
入口:example/endorser/cmd/endorser/main.go:28-104。
| 项 | 行号 |
|---|---|
| cobra 命令定义 | 28-36 |
-c/--config(必填)、--log-level(默认 INFO) flag | 38-40 |
| 加载 YAML 配置(viperutil) | 49-61 |
| 创建服务(多 namespace + executor) | 82-95 |
connection.StartService(来自 fabric-x-committer) | 104 |
构建:
sh
cd example/endorser
go build ./cmd/endorser配置样例见 example/endorser/sampleconfig/:fab-client.yaml、fab-endorser1.yaml、fab-endorser2.yaml、fabx-client.yaml、fabx-endorser1.yaml、fabx-endorser2.yaml(字段见 07-config)。
没有 Dockerfile
整个仓库无任何 Dockerfile(含 example/)。make start-x 直接拉取上游镜像 fabric-x-committer-test-node。