日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Hyperledger Fabric 核心模块(2)configtxgen工具

發布時間:2025/3/21 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Hyperledger Fabric 核心模块(2)configtxgen工具 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 說明

專門負責生成系統的創始塊和通道Channel的創始塊 。

  • order 模塊的genesis block創始塊
  • channel 模塊的 channel configuration transaction;
    channel transaction 用于在通道創建的時候廣播給排序節點。
  • anchor peer transaction
    每個組織在通道上的錨節點交易

2.configtx.yaml 配置文件

configtx.yaml配置文件用來定義相關的屬性。

  • 文件路徑是 $GOPATH/src/github.com/hyperledger/fabric/sampleconfig
  • 修改文件內容可修改相關屬性
  • 改完后要生效得copy到Orderer 節點相關的文件夾中(創始塊文件提供給 Orderer 節點使用 )

2.1 配置文件格式

configtxgen模塊的配置文件包括Fabric系統初始塊、channel初始塊文件等信息。

eg.

Profiles: #以下部分定義了整個系統配置信息# TestTwoOrgsOrdererGenesis是組織定義表示符,可以自定義,# 這個也是命令中的-profile參數對應參數TestTwoOrgsOrdererGenesis:#orderer配置屬性,這個標識不能自定義,屬于系統關鍵詞Orderer:#這個表示引用下面OrdererDefaults的屬性<<: *OrdererDefaultsOrganizations:- *OrdererOrg#定義了系統中包含的組織Consortiums:SampleConsortium:#系統中包含的組織Organizations:- *Org1 #引用下文定義的配置- *Org2#通道配置信息#通道定義標識符,可以自定義TestTwoOrgsChannel:Consortium: SampleConsortiumApplication:<<: *ApplicationDefaults #引用下文的Application定義Organizations:- *Org1- *Org2 #order節點相關的配置 Organizations:- &OrdererOrg #order節點配置信息Name: OrdererOrg #order節點名稱ID: OrdererMSP #orderer節點編號,orderer.yaml的LocalMSPID必須要和這個ID相同#MSP文件夾路徑MSPDir: /home/zym/fabric-ws/simple-demo/crypto-config/ordererOrganizations/simple-network.com/msp- &Org1Name: Org1MSP #組織名稱ID: Org1MSP #組織編號MSPDir: /home/zym/fabric-ws/simple-demo/crypto-config/peerOrganizations/org1.simple-network.com/msp #組織MSP文件名AnchorPeers: #組織的錨點信息- Host: peer0.org1.simple-network.com - Port: 7051- &Org2Name: Org2MSPID: Org2MSPMSPDir: /home/zym/fabric-ws/simple-demo/crypto-config/peerOrganizations/org2.simple-network.com/mspAnchorPeers:- Host: peer0.org2.simple-network.com- Port: 7051#orderer節點的配置信息 Orderer: &OrdererDefaults#orderer節點的共識方法OrdererType: solo#orderer的監聽地址Addresses:- orderer.simple-network.com:7050BatchTimeout: 2sBatchSize:MaxMessageCount: 10AbsoluteMaxBytes: 98 MBPreferredMaxBytes: 512 KB#kafka相關配置Kafka:Brokers:- 127.0.0.1:9092Organizations:Application: &ApplicationDefaultsOrganizations:

3. 運行命令參數

Usage of configtxgen:

參數數據類型描述
asOrgstring所屬組織,也就是為某個特定組織生成配置
channelIDstringchannel名稱,如果不指定默認是"testchainid"
inspectBlockstring打印指定區塊文件中配置內容
inspectChannelCreateTxstring打印指定創建通道交易的配置文件
outputAnchorPeersUpdatestring生成一個更新錨點的更新channel配置信息
outputBlockstring輸出區塊文件路徑
outputCreateChannelTxstring指定一個路徑,來生成channel配置文件
profilestring配置文件中的節點,用于生成相關配置文件,默認是 “SampleInsecureSolo”)
version顯示版本信息

4. 舉例

4.1 profile

  • 創建orderer的初始快
#TestTwoOrgsOrdererGenesis要個配置文件中的配置選項對應 configtxgen -profile TestTwoOrgsOrdererGenesis -outputBlock ./orderer.genesis.block
  • 生成創建channel的提案文件
configtxgen -profile TestTwoOrgsChannel -outputCreateChannelTx ./testchannel.tx -channelID testchannel
  • 創建錨點更新文件
#創建Org1MSP組織錨點更新文件 configtxgen -profile TestTwoOrgsChannel -outputAnchorPeersUpdate ./Org1MSPanchors.tx -channelID testchannel -asOrg Org1MSP#創建org2MSP組織錨點更新文件 configtxgen -profile TestTwoOrgsChannel -outputAnchorPeersUpdate ./Org2MSPanchors.tx -channelID testchannel -asOrg Org2MSP

4.2 outputBlock

依據配置SampleSingleMSPSoloV1_1將通道orderer-system-channel的創世塊寫入文件genesis_block.pb

~$ configtxgen -outputBlock genesis_block.pb -profile SampleSingleMSPSoloV1_1 -channelID orderer-system-channel

4.3 outputCreateChannelTx

依據配置Sam跑了Sin過了MSPChannelV1_1將通道創建交易寫入文件create_chan_tx.pb

~$ configtxgen -outputCreateChannelTx create_chan_tx.pb -profile SampleSingleMSPChannelV1_1 -channelID application-channel-1

4.4 inspectBlock

在屏幕以JSON格式顯示名為genesis_block.pb的創世塊的內容

~$ configtxgen -inspectBlock genesis_block.pb

4.5 inspectChannelCreateTx

在屏幕以JSON格式顯示通道創建交易文件create_chan_tx.pb的內容

~$ configtxgen -inspectChannelCreateTx create_chan_tx.pb

4.6 printOrg

基于configtx.yaml中的參數(例如MSPDir)構造一個組織定義,并在屏幕以 JSON格式顯示

~$ configtxgen -printOrg Org1

4.7 outputAnchorPeersUpdate

將配置更新交易寫入文件anchor_peer_tx.pb,該交易為配置SampleSingleMSPChannelV1_1中的組織Org1設置錨節點

~$ configtxgen -outputAnchorPeersUpdate anchor_peer_tx.pb -profile SampleSingleMSPChannelV1_1 -asOrg Org1

總結

以上是生活随笔為你收集整理的Hyperledger Fabric 核心模块(2)configtxgen工具的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。