创世区块配置和生成

创世区块要存放所有参与者的public key,防止黑客篡改。

作用为定义谁是谁,谁可以干什么。

创世区块配置文件为configtx.yaml(把first-network里的配置文件拷贝到自己的网络文件中)

cp configtx.yaml ../my-network/

进入到fabric-samples/my-network目录

cd hyfa/fabric-samples/my-network/

使用cryptogen工具为Hyperledger Fabric 网络生成制定拓扑结构的组织结构和身份证书。

sudo ../bin/cryptogen generate --config=./crypto-config.yaml

1.创建排序创世节点

 sudo ../bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

2.制定通道名称的环境变量

 export CHANNEL_NAME=mychannel

3.生成应用通道交易配置文件:指定使用configTx.yaml配置文件中的TwoOrgsChannel模板来生成新建通道的配置交易文件。

sudo ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx channelID $CHANNEL_NAME

4.同样基于configtx.yaml文件的TwoOrgsChannel模板,为每个组织分别生成锚节点更新配置。

sudo ../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
sudo ../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

5.上述所有命令执行完成后,在当前的channel-artifacts目录下会有4个被创建的文件,分别是channel.tx、genesis.block、Org1MSPanchors.tx和Org2MSPanchors.tx。

6.启动网络

sudo docker-compose -f docker-compose-cli.yaml up -d

猜你喜欢

转载自blog.csdn.net/m0_61970067/article/details/121007866