主题
fabric-smart-client · 快速开始
TIP
完整指引见 docs/README.md 与 docs/core-concepts.md。本章只列 Makefile 与 README 中可验证的命令。
工具安装
来源:Makefile:34-61。
| 目标 | 行号 | 用途 |
|---|---|---|
make install-tools | 34-38 | 从 tools/tools.go 安装所有工具 |
make install-linter-tool | 40-43 | golangci-lint v2.11.4 |
make install-fabricx-tools | 45-49 | fxconfig、configtxgen、cryptogen(Fabric-x) |
make install-fabric-bins | 51-53 | 调用 ci/scripts/download_fabric.sh(默认 3.1.4) |
make install-softhsm | 55-57 | ci/scripts/install_softhsm.sh |
make install-fsccli | 59-61 | go install ./cmd/fsccli |
版本(Makefile:8-12):
| 变量 | 值 |
|---|---|
FABRIC_VERSION | 3.1.4 |
FABRIC_TWO_DIGIT_VERSION | 由 FABRIC_VERSION 取前两段 → 3.1 |
FABRIC_X_TOOLS_VERSION | v1.0.0 |
FABRIC_X_COMMITTER_VERSION | 1.0.0 |
Proto 编译
来源:Makefile:67-69。
sh
make protos # 调用 ./scripts/compile_proto.sh拉取依赖镜像
来源:Makefile:74-100。
| 目标 | 行号 | 用途 |
|---|---|---|
make docker-images | 76 | 拉取 fabric + 监控 + 测试镜像(不含 fabricx) |
make fabric-docker-images | 78-83 | fabric-baseos、fabric-ccenv(3.1) |
make fabricx-docker-images | 85-87 | fabric-x-committer-test-node(1.0.0) |
make monitoring-docker-images | 89-94 | explorer-db / explorer / prometheus / grafana(:latest)、jaeger(2.12.0) |
make testing-docker-images | 97-100 | postgres(16.2-alpine) |
示例:Ping Pong
来源:integration/fsc/pingpong/README.md。
Initiator View(README.md:41-71,节选):
go
type Initiator struct{}
func (p *Initiator) Call(viewCtx view.Context) (interface{}, error) {
responder := view2.GetIdentityProvider(viewCtx).Identity("responder")
session, _ := viewCtx.GetSession(viewCtx.Initiator(), responder)
session.Send([]byte("ping"))
ch := session.Receive()
// ...
}Responder View(README.md:102-134,节选):
go
type Responder struct{}
func (p *Responder) Call(viewCtx view.Context) (interface{}, error) {
session := viewCtx.Session()
// 读 "ping",回 "pong"
}网络拓扑(README.md:205-218):
go
func Topology() []nwo.Topology {
topology := fsc.NewTopology()
topology.AddNodeByName("initiator").SetExecutable(...)
topology.AddNodeByName("responder").RegisterResponder(&Responder{}, &Initiator{})
return []nwo.Topology{topology}
}集成测试入口(README.md:343-352):
go
ii, _ := integration.Generate(StartPort2(), pingpong.Topology()...)
ii.Start()
initiator := ii.Client("initiator")
res, _ := initiator.CallView("init", nil)其它示例
来源:integration/。
| 目录 | 示例 |
|---|---|
integration/fabric/ | iou、atsa、events、stoprestart、twonets |
integration/fabricx/ | iou、simple、multiendorsement、deployment |
integration/fsc/ | pingpong、stoprestart |
integration/benchmark/ | grpc/remote、node/remote、views |
integration/nwo/ | 网络编排框架 |
integration/reporting/ | prometheus、jaeger |
IOU / ATSA 等示例的功能描述 [未核] —— 需逐一读其 README。