主题
fabric-x-orderer · 模块详解
本仓库 submodule:fabric-x-orderer/。本章引用的所有路径均为相对于该 submodule 根。
cmd/
| 入口 | 文件 | 入口符号 | 备注 |
|---|---|---|---|
arma | cmd/arma/main.go:9-18 | arma.NewCLI() line 16;channel 驱动 line 17 | 节点 launcher |
armageddon | cmd/armageddon/main.go:9-18 | armageddon.NewCLI() line 16;同步执行 line 17 | 配置生成工具 |
arma.NewCLI() 实现:node/server/arma.go:224-233,kingpin 应用,描述 "Launches an Arma node (Router | Assembler | Batcher | Consensus)"(line 225),4 个子命令注册见 line 231。
node/
来源:node/。
4 个角色实现
| 包 | 主 struct | 行号 |
|---|---|---|
node/router/ | Router | node/router/router.go:48 |
node/batcher/ | Batcher | node/batcher/batcher.go:54 |
node/consensus/ | Consensus | node/consensus/consensus.go:90 |
node/assembler/ | Assembler | node/assembler/assembler.go:32 |
基础设施包
| 包 | 用途 |
|---|---|
node/server/ | CLI 与节点启动;CLI struct node/server/arma.go:40 |
node/comm/ | 通信层 |
node/config/ | 节点配置 |
node/crypto/ | 密码学 |
node/delivery/ | 块交付 |
node/ledger/ | 分类账 |
node/protos/ | protobuf 定义(comm/communication.proto、state/state.proto) |
node/examples/ | 示例 / sample 测试脚本 |
node/utils/ | 工具 |
common/
来源:common/。
| 包 | 用途 |
|---|---|
common/configstore/ | 配置存储 |
common/deliver/ | 原子广播 API 实现 |
common/deliverclient/ | 块交付客户端 |
common/filerepo/ | 文件仓库 |
common/ledger/ | 分类账接口 |
common/monitoring/ | 监控 |
common/msputils/ | MSP 工具 |
common/policy/ | 策略 |
common/requestfilter/ | 请求过滤 |
common/tools/armageddon/ | armageddon 配置生成工具 |
common/types/ | 共享类型(PartyID、ShardID、BatchID 等) |
common/utils/ | 工具 |
internal/
| 包 | 用途 |
|---|---|
internal/cryptogen/ | 密钥与证书生成 |
config/
来源:config/。
| struct | 文件 | 行号 |
|---|---|---|
Configuration | config/config.go | 41-43 |
ReadConfig() | config/config.go | 47 |
NodeLocalConfig | config/local_config.go | 29-48 |
GeneralConfig | config/local_config.go | 75-104 |
PartyConfig | config/party_shared_config.go | 11-26 |
RouterNodeConfig | config/party_shared_config.go | 28-35 |
BatcherNodeConfig | config/party_shared_config.go | 37-48 |
ConsenterNodeConfig | config/party_shared_config.go | 50-59 |
AssemblerNodeConfig | config/party_shared_config.go | 61-68 |
字段详情见 07-config。
docs/
来源:docs/。
| 文档 | 章节 |
|---|---|
docs/api.md | gRPC 服务定义 + API |
docs/architecture.md | 11 个章节:Overview / Design Principles / System Components / End-to-End Transaction Flow / Data Model / Configuration and Membership / State, Persistence, and Recovery / Scaling and Fault Tolerance / Client APIs / Observability / Implementation Map |
docs/cli/arma.md | arma CLI |
docs/cli/armageddon.md | armageddon 配置工具 |
docs/monitoring/metrics.md | 监控与指标 |
deployment/
来源:deployment/、deployment/README.md。
| 子目录 / 文件 | 用途 |
|---|---|
deployment/vms/sample-config | VM 部署样本配置(config.yaml 对应 4 party、2 shard,deployment/README.md:20) |
deployment/README.md:3-5 | 两种部署形态:每节点一台 VM/裸机;或每个 party 的所有组件同处一台 VM。deployment/README.md:66 的 ### Containers 一节为空标题 |
deployment/README.md:14 | VMs 形态机器数 = 3 * party 数 + party 数 * shard 数(每 party 含 1 router、1 consenter、1 assembler,batcher 数 = shard 数) |
test/
| 子目录 | 用途 |
|---|---|
test/basic/ | 基础集成测试 |
test/faulttolerance/ | 容错测试 |
test/reconfig/ | 重配置测试(membership / identity / endpoints / params / configtx) |
test/mocks/ | mock 实现 |
test/utils/ | 测试工具 |
Makefile:135-139 还有 sample-tests。
Makefile target
关键依赖
看代码推荐路径
README.md→ Arma 协议与 4 个角色。cmd/arma/main.go→node/server/arma.go:NewCLI。- 任选一个角色,如
node/batcher/batcher.go:54看其实现。 config/系列文件 → 看 yaml 字段如何映射到 struct。docs/architecture.md→ 11 个章节的官方设计说明。deployment/vms/sample-config→ 实际 yaml 样例。