欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

hyperledger fabric环境搭建

程序员文章站 2022-07-14 16:23:04
...

生成秘钥

配置文件:crypto-config.yaml
首先,应该将整个网络的结构在该配置文件中定义好。cryptogen工具将按照网络定义分别为不同的node生成相应的公私钥文件,存放在crypto-config目录下。

cryptogen generate --config=./crypto-config.yaml
res=$?
if [ $res -ne 0 ]; then
  echo "Failed to generate certificates..."
  exit 1
fi

生成完成**之后,记得将对应**分配给node。例如,如果使用docker作为node,则记得用sed命令替换docker配置文件中的**。

生成配置区块/transaction

配置文件:configtx.yaml

genesis block

configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
res=$?
if [ $res -ne 0 ]; then
  echo "Failed to generate orderer genesis block..."
  exit 1
fi

channel configuration transaction

configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
res=$?
if [ $res -ne 0 ]; then
  echo "Failed to generate channel configuration transaction..."
  exit 1
fi

anchor peer configuration transaction

configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
res=$?
if [ $res -ne 0 ]; then
  echo "Failed to generate channel configuration transaction..."
  exit 1
fi