
Fabric源码分析
boss2967
慎独
展开
-
47.Fabric 1.0源代码分析(47)Fabric 1.0.4 go代码量统计
Fabric 1.0源代码笔记 之Fabric 1.0.4 go代码量统计1、概述除test、vendor、mocks、example、protos外,go核心代码文件341个,核心代码行63433行。find ./ |grep -vE 'test|vendor|mocks|example|protos' | grep '\.go$' | wc -l341wc -l `find ./ |...转载 2018-11-17 19:12:27 · 470 阅读 · 0 评论 -
34.Fabric 1.0源代码分析(34) Peer #peer chaincode命令及子命令实现
Fabric 1.0源代码笔记 之 Peer #peer chaincode命令及子命令实现1、peer chaincode install子命令实现(安装链码)1.0、peer chaincode install子命令概述peer chaincode install,将链码的源码和环境封装为一个链码安装打包文件,并传输到背书节点。peer chaincode install支持如下两种方...转载 2018-11-16 08:03:30 · 544 阅读 · 0 评论 -
33.Fabric 1.0源代码分析(32)Peer #peer根命令入口及加载子命令
Fabric 1.0源代码笔记 之 Peer #peer根命令入口及加载子命令1、加载环境变量配置和配置文件Fabric支持通过环境变量对部分配置进行更新,如:CORE_LOGGING_LEVEL为输出的日志级别、CORE_PEER_ID为Peer的ID等。此部分功能由第三方包viper来实现,viper除支持环境变量的配置方式外,还支持配置文件方式。viper使用方法参考:https://...转载 2018-11-17 19:10:06 · 481 阅读 · 0 评论 -
32.Fabric 1.0源代码分析(32) Peer #peer node start命令实现
Fabric 1.0源代码笔记 之 Peer #peer node start命令实现1、peer node加载子命令start和statuspeer node加载子命令start和status,代码如下:func Cmd() *cobra.Command { nodeCmd.AddCommand(startCmd()) //加载子命令start nodeCmd.AddCom...转载 2018-11-16 08:03:02 · 504 阅读 · 0 评论 -
31.Fabric 1.0源代码分析(31) Peer
Fabric 1.0源代码笔记 之 Peer1、Peer概述在Fabric中,Peer(节点)是指在网络中负责接收交易请求、维护一致账本的各个fabric-peer实例。节点之间彼此通过gRPC通信。按角色划分,Peer包括两种类型:Endorser(背书者):负责对来自客户端的交易提案进行检查和背书。Committer(提交者):负责检查交易请求,执行交易并维护区块链和账本结构。...转载 2018-11-15 09:01:41 · 722 阅读 · 0 评论 -
30.Fabric 1.0源代码分析(30) Orderer #BroadcastServer(Broadcast服务端)
Fabric 1.0源代码笔记 之 Orderer #BroadcastServer(Broadcast服务端)1、BroadcastServer概述BroadcastServer相关代码在protos/orderer、orderer目录下。protos/orderer/ab.pb.go,AtomicBroadcastServer接口定义。orderer/server.go,go,Atom...转载 2018-11-15 09:01:34 · 759 阅读 · 0 评论 -
29.Fabric 1.0源代码分析(29) Orderer #multichain(多链支持包)
Fabric 1.0源代码笔记 之 Orderer #multichain(多链支持包)1、multichain概述multichain代码集中在orderer/multichain目录下,目录结构如下:manager.go,Manager接口定义及实现。chainsupport.go,ChainSupport接口定义及实现。systemchain.go,system chain。...转载 2018-11-15 09:01:20 · 715 阅读 · 0 评论 -
28.Fabric 1.0源代码分析(28) Orderer #localconfig(Orderer配置文件定义)
Fabric 1.0源代码笔记 之 Orderer #localconfig(Orderer配置文件定义)1、配置文件定义General: #通用配置 LedgerType: file #账本类型,包括ram、json和file,其中ram保存在内存中,生产环境推荐使用file ListenAddress: 127.0.0.1 #服务绑定的监听地址 ListenPort...转载 2018-11-15 09:01:14 · 588 阅读 · 0 评论 -
27.Fabric 1.0源代码分析(27) Orderer #configupdate(处理通道配置更新)
Fabric 1.0源代码笔记 之 Orderer #configupdate(处理通道配置更新)1、configupdate概述configupdate,用于接收配置交易,并处理通道配置更新。相关代码在orderer/configupdate目录。2、SupportManager接口定义及实现2.1、SupportManager接口定义type SupportManager inte...转载 2018-11-15 09:01:07 · 554 阅读 · 0 评论 -
26.Fabric 1.0源代码分析(26)Orderer #ledger(Orderer Ledger)
Fabric 1.0源代码笔记 之 Orderer #ledger(Orderer Ledger)1、Orderer Ledger概述Orderer Ledger代码分布在orderer/ledger目录下,目录结构如下:orderer/ledger目录:ledger.go,Factory、Iterator、Reader、Writer、ReadWriter等接口定义。util.go,...转载 2018-11-15 09:00:53 · 473 阅读 · 0 评论 -
35.Fabric 1.0源代码分析(35)Peer #EndorserServer(Endorser服务端)
Fabric 1.0源代码笔记 之 Peer #EndorserServer(Endorser服务端)1、EndorserServer概述EndorserServer相关代码在protos/peer、core/endorser目录下。protos/peer/peer.pb.go,EndorserServer接口定义。core/endorser/endorser.go,EndorserSe...转载 2018-11-16 08:03:47 · 462 阅读 · 0 评论 -
35.Fabric 1.0源代码分析(35)Peer #EndorserServer(Endorser服务端)
Fabric 1.0源代码笔记 之 Peer #EndorserServer(Endorser服务端)1、EndorserServer概述EndorserServer相关代码在protos/peer、core/endorser目录下。protos/peer/peer.pb.go,EndorserServer接口定义。core/endorser/endorser.go,EndorserSe...转载 2018-11-17 19:11:28 · 467 阅读 · 0 评论 -
36.Fabric 1.0源代码分析(36) Peer #EndorserClient(Endorser客户端)
Fabric 1.0源代码笔记 之 Peer #EndorserClient(Endorser客户端)1、EndorserClient概述EndorserClient相关代码分布如下:protos/peer/peer.pb.go,EndorserClient接口及实现。peer/common/common.go,EndorserClient相关工具函数。2、EndorserClien...转载 2018-11-16 08:03:52 · 352 阅读 · 0 评论 -
46.Fabric 1.0源代码分析(46)ECDSA(椭圆曲线数字签名算法)
Fabric 1.0源代码笔记 之 ECDSA(椭圆曲线数字签名算法)1、椭圆曲线算法概述1.1、无穷远点、无穷远直线、射影平面平行线相交于无穷远点;直线上有且只有一个无穷远点;一组相互平行的直线有公共的无穷远点;平面上任何相交的两直线,有不同的无穷远点;全部无穷远点沟通一条无穷远直线;平面上全部无穷远点和全部普通点构成射影平面。1.2、射影平面点定义对于普通平面上点(x,...转载 2018-11-17 19:12:07 · 887 阅读 · 0 评论 -
45.Fabric 1.0源代码分析(45)gRPC(Fabric中注册的gRPC Service)
Fabric 1.0源代码笔记 之 -gRPC(Fabric中注册的gRPC Service)Peer节点中注册的gRPC Service,包括:Events Service(事件服务):ChatAdmin Service(管理服务):GetStatus、StartServer、GetModuleLogLevel、SetModuleLogLevel、RevertLogLevelsEndo...转载 2018-11-17 19:11:56 · 483 阅读 · 0 评论 -
44.Fabric 1.0源代码分析(44)Tx #RWSet(读写集)
Fabric 1.0源代码笔记 之 Tx #RWSet(读写集)1、RWSet概述在背书节点模拟Transaction期间,为交易准备了一个读写集合。Read Set包含模拟Transaction读取的Key和版本的列表,Write Set包含Key、写入的新值、以及删除标记(是否删除Key)。RWSet相关代码分布在protos/ledger/rwset、core/ledger/kvle...转载 2018-11-17 19:10:57 · 639 阅读 · 0 评论 -
42.Fabric 1.0源代码分析(42)scc(系统链码) #cscc(通道相关)
Fabric 1.0源代码笔记 之 scc(系统链码) #cscc(通道相关)1、cscc概述cscc代码在core/scc/cscc/configure.go。2、PeerConfiger结构体type PeerConfiger struct { policyChecker policy.PolicyChecker}//代码在core/scc/cscc/configure.g...转载 2018-11-16 08:04:46 · 432 阅读 · 0 评论 -
41.Fabric 1.0源代码分析(41)putils(protos/utils工具包)
Fabric 1.0源代码笔记 之 putils(protos/utils工具包)1、putils概述putils,即protos/utils工具包,代码分布在:protos/utils目录下。包括:txutils.go、proputils.go、commonutils.go、blockutils.go。2、txutils//TransactionAction.Payload =>...转载 2018-11-16 08:04:39 · 422 阅读 · 0 评论 -
40.Fabric 1.0源代码分析(40) Proposal(提案)
Fabric 1.0源代码笔记 之 Proposal(提案)1、Proposal概述Proposal,即向Endorser发起的提案。Proposal代码分布在protos/utils、protos/peer目录下,目录结构如下:protos/utils目录:proputils.go,Proposal工具函数。txutils.go,Proposal工具函数。protos/peer目录...转载 2018-11-16 08:04:12 · 734 阅读 · 0 评论 -
39. Fabric 1.0源代码分析(39) policy(背书策略)
Fabric 1.0源代码笔记 之 policy(背书策略)1、policy概述policy代码分布在core/policy、core/policyprovider、common/policies目录下。目录结构如下:core/policy/policy.go,PolicyChecker接口定义及实现、PolicyCheckerFactory接口定义。core/policyprovide...转载 2018-11-16 08:04:07 · 573 阅读 · 0 评论 -
38.Fabric 1.0源代码分析(38) Peer #BroadcastClient(Broadcast客户端)
Fabric 1.0源代码笔记 之 Peer #BroadcastClient(Broadcast客户端)1、BroadcastClient概述BroadcastClient代码分布如下:peer/common/ordererclient.go,BroadcastClient接口定义及实现,及BroadcastClient工具函数。protos/orderer/ab.pb.go,Atom...转载 2018-11-16 08:04:02 · 372 阅读 · 0 评论 -
37.Fabric 1.0源代码分析(37) Peer #DeliverClient(Deliver客户端)
Fabric 1.0源代码笔记 之 Peer #DeliverClient(Deliver客户端)1、DeliverClient概述DeliverClient代码分布如下:peer/channel/deliverclient.go,deliverClientIntf接口定义及实现,以及DeliverClient工具函数。protos/orderer/ab.pb.go,AtomicBroa...转载 2018-11-16 08:03:57 · 386 阅读 · 0 评论 -
25.Fabric 1.0源代码分析(25) Orderer
Fabric 1.0源代码笔记 之 Orderer1、Orderer概述Orderer,为排序节点,对所有发往网络中的交易进行排序,将排序后的交易安排配置中的约定整理为块,之后提交给Committer进行处理。Orderer代码分布在orderer目录,目录结构如下:orderer目录main.go,main入口。util.go,orderer工具函数。metadata目录,me...转载 2018-11-15 09:00:47 · 727 阅读 · 0 评论 -
23.Fabric 1.0源代码分析(23)LevelDB(KV数据库)
Fabric 1.0源代码笔记 之 LevelDB(KV数据库)1、LevelDB概述LevelDB是Google开源的持久化KV单机数据库,具有很高的随机写,顺序读/写性能,但是随机读的性能很一般,也就是说,LevelDB很适合应用在查询较少,而写很多的场景。LevelDB的特点:key和value都是任意长度的字节数组;entry(即一条K-V记录)默认是按照key的字典顺序存储的...转载 2018-11-15 09:00:33 · 763 阅读 · 0 评论 -
10.Fabric 1.0源代码分析(10)consenter(共识插件)
Fabric 1.0源代码笔记 之 consenter(共识插件)1、consenter概述consenter,即共识插件,负责接受交易信息进行排序,以及对交易进行切割并打包,打包后返回批量交易。Orderer包含三种共识插件:solo,单节点的排序功能,用于试验。kafka,基于kafka集群实现的排序,可用于生产环境。SBFT,支持拜占庭容错的排序实现,尚未完成开发。cons...转载 2018-11-13 14:26:37 · 792 阅读 · 0 评论 -
09.Fabric 1.0源代码分析(9)configtx(配置交易)体系介绍
Fabric 1.0源代码笔记 之 configtx(配置交易)1、configtx概述configtx代码分布在common/configtx目录,目录结构如下:api目录,核心接口定义,如Manager、Resources、Transactional、PolicyHandler、Proposer、Initializer。initializer.go,Resources和Initial...转载 2018-11-13 14:25:12 · 354 阅读 · 0 评论 -
08.Fabric 1.0源代码分析(8)configtx(配置交易) #genesis(系统通道创世区块)
Fabric 1.0源代码笔记 之 configtx(配置交易) #genesis(系统通道创世区块)1、genesis概述genesis,即创世区块,此处特指系统通道的创世区块。相关代码在common/genesis/genesis.go,即Factory接口及实现。2、Factory接口定义type Factory interface { Block(channelID st...转载 2018-11-13 14:24:15 · 445 阅读 · 0 评论 -
07.Fabric 1.0源代码分析(7)configtx(配置交易) #configtxgen(生成通道配置)
Fabric 1.0源代码笔记 之 configtx(配置交易) #configtxgen(生成通道配置)1、configtxgen概述configtxgen,用于生成通道配置,具体有如下三种用法:生成Orderer服务启动的初始区块(即系统通道的创世区块文件)configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./chann...转载 2018-11-13 14:18:56 · 559 阅读 · 0 评论 -
06.Fabric 1.0源代码分析(6)configtx(配置交易) #ChannelConfig(通道配置)
Fabric 1.0源代码笔记 之 configtx(配置交易) #ChannelConfig(通道配置)1、ChannelConfig概述ChannelConfig代码分布在common/config目录下。目录结构如下:channel_util.go,channel相关工具函数。orderer_util.go,orderer(系统通道)相关工具函数。application...转载 2018-11-13 10:41:16 · 435 阅读 · 0 评论 -
05.Fabric 1.0源代码分析(5)Chaincode(链码)体系总结
Fabric 1.0源代码笔记 之 Chaincode(链码)1、Chaincode概述Chaincode,即链码或智能合约,代码分布在protos/peer目录、core/chaincode和core/common/ccprovider目录,目录结构如下:protos/peer目录:chaincode.pb.go,ChaincodeDeploymentSpec、ChaincodeIn...转载 2018-11-13 10:39:09 · 643 阅读 · 0 评论 -
04.Fabric 1.0源代码分析(4)Chaincode(链码)#platforms(链码语言平台)
Fabric 1.0源代码笔记 之 Chaincode(链码) #platforms(链码语言平台)1、platforms概述platforms代码集中在core/chaincode/platforms目录下。core/chaincode/platforms目录,链码的编写语言平台实现,如golang或java。platforms.go,Platform接口定义,及platforms相...转载 2018-11-13 10:35:55 · 559 阅读 · 0 评论 -
Fabric 1.0源代码分析(3)Chaincode(链码)
Fabric 1.0源代码笔记 之 Chaincode(链码) #ChaincodeSupport(链码支持服务端)1、ChaincodeSupport概述ChaincodeSupport相关代码分布在protos/peer/chaincode_shim.pb.go和core/chaincode目录。protos/peer/chaincode_shim.pb.go,ChaincodeSup...转载 2018-11-13 10:34:13 · 728 阅读 · 0 评论 -
Fabric 1.0源代码分析(2) blockfile(区块文件存储)
Fabric 1.0源代码笔记 之 blockfile(区块文件存储)1、blockfile概述blockfile,即Fabric区块链区块文件存储,默认目录/var/hyperledger/production/ledgersData/chains,含index和chains两个子目录。其中index为索引目录,采用leveldb实现。而chains为各ledger的区块链文件,子目录以l...转载 2018-11-13 10:33:09 · 850 阅读 · 0 评论 -
11.Fabric 1.0源代码分析(11)consenter(共识插件) #filter(过滤器)
Fabric 1.0源代码笔记 之 consenter(共识插件) #filter(过滤器)1、filter概述filter代码分布在orderer/common/filter、orderer/common/configtxfilter、orderer/common/sizefilter、orderer/common/sigfilter、orderer/multichain目录下。order...转载 2018-11-13 14:27:37 · 459 阅读 · 0 评论 -
12.Fabric 1.0源代码分析(12)cryptogen(生成组织关系和身份证书)
Fabric 1.0源代码笔记 之 cryptogen(生成组织关系和身份证书)1、cryptogen概述cryptogen,用于生成组织关系和身份证书。命令为:cryptogen generate --config=./crypto-config.yaml --output ./crypto-config2、crypto-config.yaml文件示例OrdererOrgs: - ...转载 2018-11-14 08:11:09 · 472 阅读 · 0 评论 -
13.Fabric 1.0源代码分析(13)events(事件服务)
Fabric 1.0源代码笔记 之 events(事件服务)1、events概述events代码分布在events/producer和events/consumer目录下,目录结构如下:events/producer目录:生产者,提供事件服务器。producer.go,EventsServer结构体及方法。events.go,eventProcessor结构体及方法,handlerL...转载 2018-11-15 09:00:26 · 594 阅读 · 0 评论 -
22.Fabric 1.0源代码分析(22)Ledger #blkstorage(block文件存储)
Fabric 1.0源代码笔记 之 Ledger #blkstorage(block文件存储)blkstorage概述blkstorage,默认目录/var/hyperledger/production/ledgersData/chains,含index和chains两个子目录。其中index为索引目录,采用leveldb实现。而chains为各ledger的区块链文件,子目录以ledger...转载 2018-11-14 11:14:46 · 526 阅读 · 0 评论 -
21.Fabric 1.0源代码分析(21)Ledger #historydb(历史数据库)
Fabric 1.0源代码笔记 之 Ledger #historydb(历史数据库)1、historydb概述historydb,用于存储所有块读写集中写集的内容。代码分布在core/ledger/kvledger/history/historydb目录下,目录结构如下:historydb.go,定义核心接口HistoryDBProvider和HistoryDB。histmgr_hel...转载 2018-11-14 11:13:24 · 510 阅读 · 0 评论 -
20.Fabric 1.0源代码分析(20) Ledger #idStore(ledgerID数据库)
Fabric 1.0源代码笔记 之 Ledger #idStore(ledgerID数据库)1、idStore概述Fabric支持创建多个Ledger,不同Ledger以ledgerID区分。多个ledgerID及其创世区块存储在idStore数据库中,idStore数据库基于leveldb实现。idStore默认使用路径:/var/hyperledger/production/ledg...转载 2018-11-14 11:10:39 · 664 阅读 · 0 评论 -
19.Fabric 1.0源代码分析(19) Ledger #statedb(状态数据库)
Fabric 1.0源代码笔记 之 Ledger #statedb(状态数据库)1、statedb概述statedb,或VersionedDB,即状态数据库,存储了交易(transaction)日志中所有键的最新值,也称世界状态(world state)。可选择基于leveldb或cauchdb实现。statedb,代码分布在core/ledger/kvledger/txmgmt/stat...转载 2018-11-14 08:12:40 · 480 阅读 · 0 评论