In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the fabric example e2e_cli in the network_setup.sh process is how, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Network_setup.sh process Analysis network_setup.sh flow Chart in fabric sample e2e_cli
Call generateArtifacts.sh
Docker-compose up starts cli
Cli container executes script.sh script
Network_setup.sh function analysis validateArgs analysis function validateArgs () {# exit if [- z "${UP_DOWN}"] if parameter is empty; then echo "Option up / down / restart not mentioned" printHelp exit 1 fi if [- z "${CH_NAME}"] Then # if the second parameter is empty, create the channel echo "setting to default channel' mychannel'" CH_NAME=mychannel fi} function networkUp analysis with the default name of 'mychannel'
Call generateArtifacts.sh
Call docker-compose to start the container
Function networkUp () {# determines whether crypto-config exists, if it does, then execute the generateArtifacts.sh script if [- f ". / crypto-config"]; then echo "crypto-config directory already exists." Else # Generate all the artifacts that includes org certs, orderer genesis block, # channel configuration transaction source generateArtifacts.sh $CH_NAME fi # whether the fourth parameter is couchdb, if the startup parameter is accompanied by the docker-compose template file corresponding to couchdb # actual command: CHANNEL_NAME=mychannel TIMEOUT=10000 docker-compose- f docker-compose-cli.yaml-f COMPOSE_FILE_COUCH=docker-compose-couch.yaml up-d 2 > & 1 # if it is not couchdb The actual command of yaml # without couchdb is: CHANNEL_NAME=mychannel TIMEOUT=10000 docker-compose- f docker-compose-cli.yaml up-d 2 > & 1 if ["${IF_COUCHDB}" = = "couchdb"] Then CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose-f $COMPOSE_FILE-f $COMPOSE_FILE_COUCH up-d 2 > & 1 else CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose-f $COMPOSE_FILE up-d 2 > & 1 fi # determines the return value of execution. If it is not 0, the output error and exit if [$?-ne 0]; then echo "ERROR! Unable to pull the images "exit 1 fi # View the real-time log of container cli docker logs-f cli} generateArtifacts.sh function analysis
GenerateCerts replacePrivateKey generateChannelArtifacts
Function generateCerts Analysis # # Generates Org certs using cryptogen toolfunction generateCerts () {# ubuntu OS_ARCH for linux-amd64 # OS X OS_ARCH for darwin-amd64 # fabric directory corresponding subdirectory lookup file cryptogen # if the file exists # if it is not stored in the make command generation. But this make CRYPTOGEN=$FABRIC_ROOT/release/$OS_ARCH/bin/cryptogen if [- f "$CRYPTOGEN"] Then echo "Using cryptogen-> $CRYPTOGEN" else echo "Building cryptogen" make-C $FABRIC_ROOT release fi # actual command cryptogen generate-- config=./crypto-config.yaml # TODO to be improved echo echo "# # # "echo" # Generate certificates using cryptogen tool # "echo" # "$CRYPTOGEN generate-- Config=./crypto-config.yaml echo} replacePrivateKey## Using docker-compose template replace private key file names with constantsfunction replacePrivateKey () {# if it is OS X, the system parameter is-it Otherwise, adding ""-I before-I # or-I can avoid misreporting ARCH= `uname-s in OS X | grep Darwin` if ["$ARCH" = = "Darwin"] Then OPTS= "- it" else OPTS= "- I" fi # copy the docker-compose-e2e-template.yaml file And the new file is named docker-compose-e2e.yaml cp docker-compose-e2e-template.yaml docker-compose-e2e.yaml # get the file name at the end of _ sk in the crypto-config/peerOrganizations/org1.example.com/ca/ directory # replace the CA1_PRIVATE_KEY in the above file with the above file name #-I directly modify the text file content # s replace the specified character Using the suffix / g tag replaces all matching CURRENT_DIR=$PWD cd crypto-config/peerOrganizations/org1.example.com/ca/ PRIV_KEY=$ (ls * _ sk) cd $CURRENT_DIR sed $OPTS "s docker-compose-e2e.yaml cd crypto-config/peerOrganizations/org2.example.com/ca/ PRIV CA1 private key on each line ${PRIV_KEY} / g" _ KEY=$ (ls * _ sk) cd $CURRENT_DIR sed $OPTS "CA2 private key generateChannelArtifacts## Generate orderer genesis block ${PRIV_KEY} / g" docker-compose-e2e.yaml} Channel configuration transaction and anchor peer update transactionsfunction generateChannelArtifacts () {# ubuntu OS_ARCH for linux-amd64 # OS X OS_ARCH for darwin-amd64 # fabric directory corresponding subdirectory lookup file cryptogen # if this file exists # if it does not exist execute the make command to generate CONFIGTXGEN=$FABRIC_ROOT/release/$OS_ARCH/bin/configtxgen if [- f "$CONFIGTXGEN"] Then echo "Using configtxgen-> $CONFIGTXGEN" else echo "Building configtxgen" make-C $FABRIC_ROOT release fi # use tool configtxgen to generate Genesis Block # # profile specify configuration item # # outputBlock execution generation file path in configtx.yaml, protobuf serialization format # # you can use the tool to view it in json format Configtxgen-inspectBlock genesis.block echo "#" echo "# Generating Orderer Genesis block #" echo "# # "# Note: For some unknown reason (at least for now) the block file can't be # named orderer.genesis.block or the orderer will fail to launch! $CONFIGTXGEN-profile TwoOrgsOrdererGenesis-outputBlock. / channel-artifacts/genesis.block # # use the tool Configtxgen generates channel.tx # # outputCreateChannelTx specifies the generated file path Protobuf serialization format # # can be viewed in json format with tools Configtxgen-inspectChannelCreateTx channel.tx echo echo "#" echo "# Generating channel configuration transaction 'channel.tx' #" echo "# # "$CONFIGTXGEN-profile TwoOrgsChannel-outputCreateChannelTx. / channel-artifacts/channel.tx-channelID $CHANNEL_NAME # generate Org1MSPanchors.tx echo echo using the tool configtxgen" # # "echo" # Generating anchor peer update for Org1MSP # "echo" # # # # "$CONFIGTXGEN-profile TwoOrgsChannel-outputAnchorPeersUpdate. / channel-artifacts/Org1MSPanchors.tx-channelID $CHANNEL_NAME-asOrg Org1MSP # generate Org2MSPanchors.tx echo echo using tool configtxgen" # # # # "echo" # Generating anchor peer update for Org2MSP # "echo" # # # "$CONFIGTXGEN-profile TwoOrgsChannel-outputAnchorPeersUpdate. / channel-artifacts/Org2MSPanchors.tx-channelID $CHANNEL_NAME-asOrg Org2MSP echo} docker-compose launch Container Startup Command CHANNEL_NAME=mychannel TIMEOUT=10000 docker-compose- f docker-compose-cli.yaml up-d 2 > & 1script.sh Analysis
Create a channel
Join the channel
Set up anchor
Install chaincode
Instantiate chaincode
Query / call chaincode
Thank you for reading this article carefully. I hope the article "what is the process of network_setup.sh in fabric sample e2e_cli" shared by the editor will be helpful to you. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.