区块链教程Fabric1.0源代码分析Orderer localconfig

简介:

  兄弟连区块链教程Fabric1.0源代码分析Orderer localconfig,2018年下半年,区块链行业正逐渐褪去发展之初的浮躁、回归理性,表面上看相关人才需求与身价似乎正在回落。但事实上,正是初期泡沫的渐退,让人们更多的关注点放在了区块链真正的技术之上。

Fabric 1.0源代码笔记 之 Orderer #localconfig(Orderer配置文件定义)

1、配置文件定义

General: #通用配置
    LedgerType: file #账本类型,包括ram、json和file,其中ram保存在内存中,生产环境推荐使用file
    ListenAddress: 127.0.0.1 #服务绑定的监听地址
    ListenPort: 7050 #服务绑定的监听端口
    TLS: #启用TLS时的相关配置
        Enabled: false #是否启用TLS
        PrivateKey: tls/server.key #Orderer签名私钥
        Certificate: tls/server.crt #Orderer身份证书
        RootCAs: #信任的根证书
          - tls/ca.crt
        ClientAuthEnabled: false #是否对客户端也进行认证
        ClientRootCAs:
    LogLevel: info #日志级别
    LogFormat: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'
    GenesisMethod: provisional #初始区块的提供方式,支持provisional或file,前者基于GenesisProfile指定的configtx.yaml中Profile生成,后者基于指定的初始区块文件
    GenesisProfile: SampleInsecureSolo #provisional方式生成初始区块时采用的Profile
    GenesisFile: genesisblock #使用现成的初始区块文件时,文件的路径
    LocalMSPDir: msp #本地msp文件的路径
    LocalMSPID: DEFAULT #MSP的ID
    Profile: #是否启用go profiling
        Enabled: false
        Address: 0.0.0.0:6060
    BCCSP: #密码库机制等,可以为SW(软件实现)或PKCS11(硬件安全模块)
        Default: SW
        SW:
            Hash: SHA2 #哈希算法类型
            Security: 256
            FileKeyStore: #本地私钥文件路径,默认指向<mspConfigPath>/keystore
                KeyStore:
FileLedger: #基于文件的账本的配置
    Location: /var/hyperledger/production/orderer #存放区块文件的位置,一般为/var/hyperledger/production/orderer/目录
    Prefix: hyperledger-fabric-ordererledger #如果不指定Location,则在临时目录下创建账本时使用的目录名称
RAMLedger: #基于内存的账本最多保留的区块个数
    HistorySize: 1000
Kafka: #Orderer使用Kafka集群作为后端时,Kafka的配置
    Retry: #Kafka未就绪时Orderer的重试配置,orderer会利用sarama客户端为channel创建一个producer、一个consumer,分别向Kafka写和读数据
        ShortInterval: 5s #操作失败后的快速重试阶段的间隔
        ShortTotal: 10m #快速重试阶段最多重试多长时间
        LongInterval: 5m #快速重试阶段仍然失败后进入慢重试阶段,慢重试阶段的时间间隔
        LongTotal: 12h #慢重试阶段最多重试多长时间
        NetworkTimeouts: #sarama网络超时时间
            DialTimeout: 10s
            ReadTimeout: 10s
            WriteTimeout: 10s
        Metadata: #Kafka集群leader选举中的metadata请求参数
            RetryBackoff: 250ms
            RetryMax: 3
        Producer: #发送消息到Kafka集群的超时
            RetryBackoff: 100ms
            RetryMax: 3
        Consumer: #从Kafka集群读取消息的超时
            RetryBackoff: 2s
    Verbose: false #是否开启Kafka客户端的调试日志
    TLS: #Kafka集群的连接启用TLS时的相关配置
      Enabled: false #是否启用TLS,默认不开启
      PrivateKey: #Orderer证明身份用的签名私钥
      Certificate: #Kafka身份证书
      RootCAs: #验证Kafka证书时的CA证书
    Version: #Kafka版本号
#代码在/etc/hyperledger/fabric/orderer.yaml

2、TopLevel结构体定义

type TopLevel struct {
    General    General
    FileLedger FileLedger
    RAMLedger  RAMLedger
    Kafka      Kafka
}

type General struct {
    LedgerType     string
    ListenAddress  string
    ListenPort     uint16
    TLS            TLS
    GenesisMethod  string
    GenesisProfile string
    GenesisFile    string
    Profile        Profile
    LogLevel       string
    LogFormat      string
    LocalMSPDir    string
    LocalMSPID     string
    BCCSP          *bccsp.FactoryOpts
}

type TLS struct {
    Enabled           bool
    PrivateKey        string
    Certificate       string
    RootCAs           []string
    ClientAuthEnabled bool
    ClientRootCAs     []string
}

type Profile struct {
    Enabled bool
    Address string
}

type FileLedger struct {
    Location string
    Prefix   string
}

type RAMLedger struct {
    HistorySize uint
}

type Kafka struct {
    Retry   Retry
    Verbose bool
    Version sarama.KafkaVersion
    TLS     TLS
}

type Retry struct {
    ShortInterval   time.Duration
    ShortTotal      time.Duration
    LongInterval    time.Duration
    LongTotal       time.Duration
    NetworkTimeouts NetworkTimeouts
    Metadata        Metadata
    Producer        Producer
    Consumer        Consumer
}

type NetworkTimeouts struct {
    DialTimeout  time.Duration
    ReadTimeout  time.Duration
    WriteTimeout time.Duration
}

type Metadata struct {
    RetryMax     int
    RetryBackoff time.Duration
}

type Producer struct {
    RetryMax     int
    RetryBackoff time.Duration
}

type Consumer struct {
    RetryBackoff time.Duration
}
//代码在orderer/localconfig/config.go
相关文章
|
26天前
|
安全 区块链
区块链积分商城系统开发详细指南//需求功能/指南教程/源码流程
Developing a blockchain points mall system involves multiple aspects such as blockchain technology, smart contracts, front-end development, and business logic design. The following is the general process for developing a blockchain points mall system
|
23天前
|
供应链 区块链 数据安全/隐私保护
探索区块链技术在金融领域的应用与前景分析
本文将深入探讨区块链技术在金融领域的具体应用场景,分析其优势与挑战,并展望未来发展趋势。通过案例分析和技术解析,揭示区块链技术在金融行业中的革新意义及前景。
|
1月前
|
安全 区块链
区块链游戏系统开发步骤需求丨功能逻辑丨规则玩法丨指南教程丨源码详细
Developing blockchain game systems has been a highly anticipated field in recent years. By combining blockchain technology and game mechanics, players can enjoy a brand new gaming experience and higher game credibility.
|
7月前
|
区块链
区块链的发币流程技术分析
区块链现在是发展的如火如荼,很多人都想趁着这个风口,投入区块链创业的浪潮中。 那么我们该怎么做才能抓住这个机会呢? 进行区块链发币要求是很多的,主要有以下几个步骤。
|
7月前
|
安全 算法 区块链
区块链交易所开发技术说明:智能合约设计与实现步骤实现分析
智能合约是区块链技术的核心应用,其能够自动执行、验证和执行合同,并以可验证的方式进行操作。在区块链交易所中,智能合约扮演着重要的角色,它们保证了交易的透明性、效率和安全性。作为一名专业的交易所开发团队一员,在交易所开发这块拥有相对成熟的开发技术,目前已经有成熟的区块链交易所开发案例。本文将介绍如何设计和实现可靠的智能合约来支持区块链交易所。
|
7月前
|
区块链 安全 数据安全/隐私保护
区块链LP流动性SWAP博饼交易所系统开发分析模式
Web3在生态的每一个要素中,都体现出了去中心化的特点。
|
7月前
|
SQL 安全 区块链
交易所系统开发(案例项目)丨区块链交易所系统开发(稳定版)/成熟技术/步骤逻辑/源码教程
The development of a blockchain exchange system involves complex technologies and functions.
|
8月前
|
区块链
区块链DAO众筹资金模式合约开发源代码详情
// 众筹函数,向DAO众筹资金 function contribute() public { uint contributionAmount = (unitPrice * msg.value).div(10 ether); // 计算贡献金额,最小单位为0.01ETH
|
8月前
|
安全 Go 区块链
区块链游戏链游系统开发功能详情丨方案逻辑丨开发项目丨案例分析丨源码规则
 In recent years, with the continuous development of blockchain technology, NFTs (non homogeneous tokens) and DAPPs (decentralized applications) have emerged in the gaming industry.
|
9月前
|
存储 前端开发 JavaScript
区块链交易所系统开发(正式版)丨DEX/DEFI/SWAP去中心化智能合约系统开发详细案例/方案项目/技术分析/源码功能
  去中心化存储技术是一种新型存储技术,它改变了传统的集中式存储技术,将数据从单一位置移到多个位置,这样就消除了存储数据的中心机构或服务器的责任,增加了安全性和数据的有效存储,确保用户的数据安全性。