美文网首页我爱编程
Fabric_Build Your First Network

Fabric_Build Your First Network

作者: zlyyuan | 来源:发表于2018-04-17 11:10 被阅读0次

    *

    * Generating certs and genesis block for with channel 'mychannel' and CLI timeout of '10'

    *

    ./byfn.sh -m generate

    *

    * Bring the network up, compile Golang chaincode images and spin up the corresponding containers.

    * launch all of the containers, and then drive a complete end-to-end application scenario

    *

    ./byfn.sh -m up

    *

    * Bring down the network up kill your containers, remove the crypto material and four artifacts,

    * and delete the chaincode images from your Docker Registry

    *

    ./byfn.sh -m down

    *

    * generate the keys/ certs for network configuration defined in ctypto-config.yaml

    *

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

    *

    * 1. Tell the configtxgen tool where the configtx.taml

    * 2. To create the orderer genesis block;

    *

    export FABRIC_CFG_PATH=$PWD;

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

    *

    * Create Channel Configuration Transaction

    *

    export CHANNEL_NAME=mychannel  && ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME

    *

    * Define the anchor peer for Org1 on the above channel by specifying -channelID flag

    *

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

    *

    * Define the anchor peer for Org2 on the above channel by specifying -channelID flag

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

    *

    * Start above defined network

    *

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

    docker exec -it cli bash

    *

    * Within started cli console

    * 'root@0d78bb69300d:/opt/gopath/src/github.com/hyperledger/fabric/peer#'

    * to create a channel

    *

    ----------------------------------------------------

    export CHANNEL_NAME=mychannel

    # the channel.tx file is mounted in the channel-artifacts directory within your CLI container

    # as a result, we pass the full path for the file

    # we also pass the path for the orderer ca-cert in order to verify the TLS handshake

    # be sure to export or replace the $CHANNEL_NAME variable appropriately

    peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

    ----------------------------------------------------

    *

    *  Let peer0.org1.example.com to join the channel.

    *

    peer channel join -b mychannel.block

    *

    * Change environment variables

    * Let peer0.org2.example.com to join the channel.

    *

    ----------------------------------------------------

    CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051

    CORE_PEER_LOCALMSPID="Org2MSP"

    CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt

    peer channel join -b mychannel.block

    ----------------------------------------------------

    *

    * By updating the channel definition, to define the anchor peer for Org1 as 'peer0.or1.example.com'

    *

    ----------------------------------------------------

    peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org1MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

    ----------------------------------------------------

    *

    * By updating the channel definition, to define the anchor peer for Org2 as 'peer0.or2.example.com'

    *

    ----------------------------------------------------

    CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp

    CORE_PEER_ADDRESS=peer0.org2.example.com:7051

    CORE_PEER_LOCALMSPID="Org2MSP"

    CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt

    peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org2MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem

    ----------------------------------------------------

    Install & Instantiate Chaincode

    *

    * Install chaincode for GoLang

    *

    peer chaincode install -n mycc -v 1.0 -p github.com/chaincode/chaincode_example02/go/

    *

    * Instantiate chaincode for GoLang

    *

    # be sure to replace the $CHANNEL_NAME environment variable if you have not exported it

    # if you did not install your chaincode with a name of mycc, then modify that argument as well

    peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C $CHANNEL_NAME -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"

    相关文章

      网友评论

        本文标题:Fabric_Build Your First Network

        本文链接:https://www.haomeiwen.com/subject/cxeukftx.html