Skip to content

fabric-x-sdk · 快速开始

本仓库无独立 server;"运行"等价于运行 example/endorser 或集成测试。

Makefile target

来源:Makefile

target行号用途
checks2-5gofmtgo vetaddlicense
unit-tests8-9短模式单元测试
init-x12-14生成 crypto + genesis block
clean-x17-18清空 crypto
start-x21-42启动 Fabric-X test committer + 创建 namespace
test-x45-46TestFabricXCommitter 集成测试
stop-x49-50停 committer
start-fablo53-54启 fablo 网络
stop-fablo57-58停 fablo
test-fablo61-62TestFablo 测试
clean-fablo65-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_DIR
  • SC_SIDECAR_ORDERER_IDENTITY_MSP_ID
  • SC_SIDECAR_ORDERER_CHANNEL_ID
  • SC_SIDECAR_ORDERER_SIGNED_ENVELOPES
  • SC_QUERY_SERVICE_SERVER_ENDPOINT
  • SC_ORDERER_BLOCK_SIZE

启 fablo(另一种网络)

来源:Makefile:53-67

sh
make start-fablo
make test-fablo
make stop-fablo
make clean-fablo

fablo 网络位于 testdata/fablo/,由 ./fablo up / ./fablo prune 驱动(Makefile:54, 58, 66)。

example/endorser

来源:example/endorser/README.mdexample/endorser/cmd/endorser/main.go

入口:example/endorser/cmd/endorser/main.go:28-104

行号
cobra 命令定义28-36
-c/--config(必填)、--log-level(默认 INFO) flag38-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.yamlfab-endorser1.yamlfab-endorser2.yamlfabx-client.yamlfabx-endorser1.yamlfabx-endorser2.yaml(字段见 07-config)。

没有 Dockerfile

整个仓库无任何 Dockerfile(含 example/)。make start-x 直接拉取上游镜像 fabric-x-committer-test-node

下一步