Skip to content

fabric-x-orderer · 模块详解

本仓库 submodule:fabric-x-orderer/。本章引用的所有路径均为相对于该 submodule 根。

cmd/

入口文件入口符号备注
armacmd/arma/main.go:9-18arma.NewCLI() line 16;channel 驱动 line 17节点 launcher
armageddoncmd/armageddon/main.go:9-18armageddon.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/Routernode/router/router.go:48
node/batcher/Batchernode/batcher/batcher.go:54
node/consensus/Consensusnode/consensus/consensus.go:90
node/assembler/Assemblernode/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.protostate/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/共享类型(PartyIDShardIDBatchID 等)
common/utils/工具

internal/

用途
internal/cryptogen/密钥与证书生成

config/

来源:config/

struct文件行号
Configurationconfig/config.go41-43
ReadConfig()config/config.go47
NodeLocalConfigconfig/local_config.go29-48
GeneralConfigconfig/local_config.go75-104
PartyConfigconfig/party_shared_config.go11-26
RouterNodeConfigconfig/party_shared_config.go28-35
BatcherNodeConfigconfig/party_shared_config.go37-48
ConsenterNodeConfigconfig/party_shared_config.go50-59
AssemblerNodeConfigconfig/party_shared_config.go61-68

字段详情见 07-config

docs/

来源:docs/

文档章节
docs/api.mdgRPC 服务定义 + API
docs/architecture.md11 个章节: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.mdarma CLI
docs/cli/armageddon.mdarmageddon 配置工具
docs/monitoring/metrics.md监控与指标

deployment/

来源:deployment/deployment/README.md

子目录 / 文件用途
deployment/vms/sample-configVM 部署样本配置(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:14VMs 形态机器数 = 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

06-api · Makefile target

关键依赖

02-architecture · 关键依赖

看代码推荐路径

  1. README.md → Arma 协议与 4 个角色。
  2. cmd/arma/main.gonode/server/arma.go:NewCLI
  3. 任选一个角色,如 node/batcher/batcher.go:54 看其实现。
  4. config/ 系列文件 → 看 yaml 字段如何映射到 struct。
  5. docs/architecture.md → 11 个章节的官方设计说明。
  6. deployment/vms/sample-config → 实际 yaml 样例。