Hyperledger Fabric 整理體系:
./byfn.sh up
創(chuàng)建網(wǎng)絡(luò)
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=1.4.3
DOCKER_IMAGE_VERSION=1.4.3
Creating network "net_byfn" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating peer0.org2.example.com ... done
Creating orderer.example.com ... done
Creating peer1.org1.example.com ... done
Creating peer0.org1.example.com ... done
Creating peer1.org2.example.com ... done
Creating cli ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
632649cddd91 hyperledger/fabric-tools:latest "/bin/bash" 1 second ago Up Less than a second cli
bc6ee732aedb hyperledger/fabric-peer:latest "peer node start" 5 seconds ago Up 2 seconds 0.0.0.0:8051->8051/tcp peer1.org1.example.com
e8507abbf2ea hyperledger/fabric-peer:latest "peer node start" 5 seconds ago Up 2 seconds 0.0.0.0:7051->7051/tcp peer0.org1.example.com
8db7d4d1f33e hyperledger/fabric-peer:latest "peer node start" 5 seconds ago Up 2 seconds 0.0.0.0:10051->10051/tcp peer1.org2.example.com
be15e6c4c248 hyperledger/fabric-orderer:latest "orderer" 5 seconds ago Up 1 second 0.0.0.0:7050->7050/tcp orderer.example.com
14b17c7a4473 hyperledger/fabric-peer:latest "peer node start" 5 seconds ago Up 2 seconds 0.0.0.0:9051->9051/tcp peer0.org2.example.com
script.sh執(zhí)行了一系列網(wǎng)絡(luò)構(gòu)建工作:
- 創(chuàng)建channel,并將所有peers加入channel
- 設(shè)定每個(gè)org的anchor peer
- intall chaincode到兩個(gè)anchor peer,實(shí)例化其中一個(gè)
- query和invoke操作
- instantiateChaincode chaincode到另一個(gè)結(jié)點(diǎn),并在其上query
____ _____ _ ____ _____
/ ___| |_ _| / \ | _ \ |_ _|
\___ \ | | / _ \ | |_) | | |
___) | | | / ___ \ | _ < | |
|____/ |_| /_/ \_\ |_| \_\ |_|
Build your first network (BYFN) end-to-end test
# 該命令執(zhí)行后,會(huì)在本地生成一個(gè)與應(yīng)用通道名稱同名的初始區(qū)塊mychannel.block,網(wǎng)絡(luò)節(jié)點(diǎn)只有擁有該文件才可以加入創(chuàng)建的應(yīng)用通道中。
# 參數(shù)說明
# -o orderer節(jié)點(diǎn)地址
# -c 要?jiǎng)?chuàng)建的應(yīng)用通道的名稱(必須與在創(chuàng)建應(yīng)用通道交易配置文件時(shí)的通道名稱一致)
# -f 創(chuàng)建應(yīng)用通道時(shí),所使用的應(yīng)用通道交易配置文件
# --tls 開啟TLS驗(yàn)證
# --cafile 指定TLS_CA證書所在路徑
Channel name : mychannel
Creating channel...
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-25 02:33:31.229 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:33:31.280 UTC [cli.common] readBlock -> INFO 002 Received block: 0
===================== Channel 'mychannel' created =====================
# 應(yīng)用通道所包含組織的成員節(jié)點(diǎn)加入通道中
# join命令:將本Peer節(jié)點(diǎn)加入到應(yīng)用通道中
# 參數(shù)說明:
# -b:指定當(dāng)前節(jié)點(diǎn)要加入/連接到哪個(gè)應(yīng)用通道
Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-25 02:33:31.350 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:33:31.384 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-25 02:33:34.456 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:33:34.490 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-25 02:33:37.566 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:33:37.596 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org2 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-25 02:33:40.698 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:33:40.732 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org2 joined channel 'mychannel' =====================
# 使用Org1的管理員身份更新錨節(jié)點(diǎn)配置
Updating anchor peers for org1...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-25 02:33:43.845 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:33:43.875 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' =====================
# 使用Org2的管理員身份更新錨節(jié)點(diǎn)配置
Updating anchor peers for org2...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-25 02:33:46.967 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:33:46.981 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================
# 管理Chaincode生命周期共有五個(gè)命令:
# install:將已編寫完成的鏈碼安裝在網(wǎng)絡(luò)節(jié)點(diǎn)中
# instantiate:對(duì)已安裝的鏈碼進(jìn)行實(shí)例化
# upgrade:對(duì)已有鏈碼進(jìn)行升級(jí)。鏈碼可以在安裝后根據(jù)具體需求的變化進(jìn)行升級(jí)。
# package:對(duì)指定鏈碼進(jìn)行打包的操作
# signpackage:簽名
# 安裝鏈碼
# 參數(shù)說明
# -n:指定要安裝的鏈碼的名稱
# -v:指定鏈碼的版本
# -p:指定要安裝的鏈碼的所在路徑
Installing chaincode on peer0.org1...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-11-25 02:33:50.064 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-25 02:33:50.064 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-11-25 02:33:50.654 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
===================== Chaincode is installed on peer0.org1 =====================
Install chaincode on peer0.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-11-25 02:33:50.753 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-25 02:33:50.753 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-11-25 02:33:50.901 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
===================== Chaincode is installed on peer0.org2 =====================
# 實(shí)例化鏈碼
# 參數(shù)說明
# -o:指定Orderer服務(wù)節(jié)點(diǎn)地址
# --tls:開啟TLS驗(yàn)證
# --cafile:指定TLS_CA證書的所在路徑
# -n:指定要實(shí)例化的鏈碼名稱,必須與安裝時(shí)指定的鏈碼名稱相同
# -v:指定要實(shí)例化的鏈碼版本號(hào),必須與安裝時(shí)指定的鏈碼版本號(hào)相同
# -C:指定通道名稱
# -c:實(shí)例化鏈碼時(shí)指定的參數(shù)
# -P:指定背書策略
Instantiating chaincode on peer0.org2...
+ peer chaincode instantiate -o orderer.example.com:7050 --tls true --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 mychannel -n mycc -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P 'AND (''Org1MSP.peer'',''Org2MSP.peer'')'
+ res=0
+ set +x
2019-11-25 02:33:50.984 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-25 02:33:50.984 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
===================== Chaincode is instantiated on peer0.org2 on channel 'mychannel' =====================
# 查詢鏈碼
# 參數(shù)說明
# -n:指定要調(diào)用的鏈碼名稱高
# -C:指定通道名稱
# -c:指定調(diào)用鏈碼時(shí)所需要的參數(shù)
Querying chaincode on peer0.org1...
===================== Querying on peer0.org1 on channel 'mychannel'... =====================
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
Attempting to Query peer0.org1 ...3 secs
+ res=0
+ set +x
100
===================== Query successful on peer0.org1 on channel 'mychannel' =====================
# 調(diào)用鏈碼
# 參數(shù)說明
# -o:指定Orderer服務(wù)節(jié)點(diǎn)地址
# --tls:開啟TLS驗(yàn)證
# --cafile:指定TLS_CA證書的所在路徑
# -n:指定要實(shí)例化的鏈碼名稱,必須與安裝時(shí)指定的鏈碼名稱相同
# -v:指定要實(shí)例化的鏈碼版本號(hào),必須與安裝時(shí)指定的鏈碼版本號(hào)相同
# -C:指定通道名稱
# -c:實(shí)例化鏈碼時(shí)指定的參數(shù)
Sending invoke transaction on peer0.org1 peer0.org2...
+ peer chaincode invoke -o orderer.example.com:7050 --tls true --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 mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2019-11-25 02:34:20.520 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' =====================
Installing chaincode on peer1.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2019-11-25 02:34:20.618 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-25 02:34:20.618 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-11-25 02:34:20.795 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
===================== Chaincode is installed on peer1.org2 =====================
Querying chaincode on peer1.org2...
===================== Querying on peer1.org2 on channel 'mychannel'... =====================
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
Attempting to Query peer1.org2 ...3 secs
+ res=0
+ set +x
90
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
========= All GOOD, BYFN execution completed ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
?
./startFabric.sh
打印日志:證書生成
##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ cryptogen generate --config=./crypto-config.yaml
org1.example.com
org2.example.com
+ res=0
+ set +x
Generate CCP files for Org1 and Org2
/Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/../bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
CONSENSUS_TYPE=solo
+ '[' solo == solo ']'
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2019-11-25 10:52:33.209 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-11-25 10:52:33.289 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: solo
2019-11-25 10:52:33.289 CST [common.tools.configtxgen.localconfig] Load -> INFO 003 Loaded configuration: /Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
2019-11-25 10:52:33.352 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 004 orderer type: solo
2019-11-25 10:52:33.352 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 005 Loaded configuration: /Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
2019-11-25 10:52:33.357 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Generating genesis block
2019-11-25 10:52:33.358 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
+ set +x
#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2019-11-25 10:52:33.381 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-11-25 10:52:33.445 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
2019-11-25 10:52:33.508 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-11-25 10:52:33.508 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
2019-11-25 10:52:33.508 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 005 Generating new channel configtx
2019-11-25 10:52:33.511 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 006 Writing new channel tx
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
2019-11-25 10:52:33.536 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-11-25 10:52:33.654 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
2019-11-25 10:52:33.719 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-11-25 10:52:33.719 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
2019-11-25 10:52:33.719 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2019-11-25 10:52:33.719 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x
#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
2019-11-25 10:52:33.743 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2019-11-25 10:52:33.807 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
2019-11-25 10:52:33.870 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 orderer type: solo
2019-11-25 10:52:33.870 CST [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 004 Loaded configuration: /Users/macserver/Documents/BlockChain/src/github.com/hyperledger/fabric-samples/first-network/configtx.yaml
2019-11-25 10:52:33.871 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 005 Generating anchor peer update
2019-11-25 10:52:33.871 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 006 Writing anchor peer update
+ res=0
+ set +x
創(chuàng)建網(wǎng)絡(luò)
Creating network "net_byfn" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating ca_peerOrg2 ... done
Creating couchdb0 ... done
Creating ca_peerOrg1 ... done
Creating orderer.example.com ... done
Creating couchdb2 ... done
Creating couchdb3 ... done
Creating couchdb1 ... done
Creating peer0.org1.example.com ... done
Creating peer0.org2.example.com ... done
Creating peer1.org1.example.com ... done
Creating peer1.org2.example.com ... done
Creating cli ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f198d322329e hyperledger/fabric-tools:latest "/bin/bash" 1 second ago Up Less than a second cli
71f4bda269ba hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up Less than a second 0.0.0.0:10051->10051/tcp peer1.org2.example.com
f0fab7ad25d3 hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up 1 second 0.0.0.0:8051->8051/tcp peer1.org1.example.com
24978a7f9bca hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up 1 second 0.0.0.0:9051->9051/tcp peer0.org2.example.com
baf7c6d80e94 hyperledger/fabric-peer:latest "peer node start" 3 seconds ago Up 1 second 0.0.0.0:7051->7051/tcp peer0.org1.example.com
16df6d0a6142 hyperledger/fabric-couchdb "tini -- /docker-ent…" 5 seconds ago Up 2 seconds 4369/tcp, 9100/tcp, 0.0.0.0:8984->5984/tcp couchdb3
abd9c0985dd6 hyperledger/fabric-ca:latest "sh -c 'fabric-ca-se…" 5 seconds ago Up 2 seconds 0.0.0.0:7054->7054/tcp ca_peerOrg1
9281918bebce hyperledger/fabric-orderer:latest "orderer" 5 seconds ago Up 2 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
683dec07fae9 hyperledger/fabric-couchdb "tini -- /docker-ent…" 5 seconds ago Up 2 seconds 4369/tcp, 9100/tcp, 0.0.0.0:7984->5984/tcp couchdb2
9c14592e3eec hyperledger/fabric-couchdb "tini -- /docker-ent…" 5 seconds ago Up 2 seconds 4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp couchdb1
a4861b271b4d hyperledger/fabric-couchdb "tini -- /docker-ent…" 5 seconds ago Up 3 seconds 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb0
84e03acdd25c hyperledger/fabric-ca:latest "sh -c 'fabric-ca-se…" 5 seconds ago Up 3 seconds 7054/tcp, 0.0.0.0:8054->8054/tcp ca_peerOrg2
____ _____ _ ____ _____
/ ___| |_ _| / \ | _ \ |_ _|
\___ \ | | / _ \ | |_) | | |
___) | | | / ___ \ | _ < | |
|____/ |_| /_/ \_\ |_| \_\ |_|
Build your first network (BYFN) end-to-end test
Channel name : mychannel
Creating channel...
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-25 02:52:39.435 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:52:39.497 UTC [cli.common] readBlock -> INFO 002 Received block: 0
===================== Channel 'mychannel' created =====================
Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=1
+ set +x
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.24.0.9:7051: connect: connection refused"
peer0.org1 failed to join the channel, Retry after 3 seconds
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-25 02:52:42.758 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:52:43.062 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-25 02:52:46.141 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:52:46.251 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org1 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-25 02:52:49.325 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:52:49.464 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org2 joined channel 'mychannel' =====================
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2019-11-25 02:52:52.537 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:52:52.652 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org2 joined channel 'mychannel' =====================
Updating anchor peers for org1...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-25 02:52:55.732 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:52:55.749 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' =====================
Updating anchor peers for org2...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2019-11-25 02:52:58.803 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2019-11-25 02:52:58.820 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' =====================
========= All GOOD, BYFN execution completed ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
添加智能合約
+ echo 'Installing smart contract on peer0.org1.example.com'
Installing smart contract on peer0.org1.example.com
+ docker exec -e CORE_PEER_LOCALMSPID=Org1MSP -e CORE_PEER_ADDRESS=peer0.org1.example.com:7051 -e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp -e CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt cli peer chaincode install -n fabcar -v 1.0 -p github.com/chaincode/fabcar/go -l golang
2019-11-25 02:53:02.029 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-25 02:53:02.029 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-11-25 02:53:02.240 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
+ echo 'Installing smart contract on peer0.org2.example.com'
Installing smart contract on peer0.org2.example.com
+ docker exec -e CORE_PEER_LOCALMSPID=Org2MSP -e CORE_PEER_ADDRESS=peer0.org2.example.com:9051 -e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp -e 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 cli peer chaincode install -n fabcar -v 1.0 -p github.com/chaincode/fabcar/go -l golang
2019-11-25 02:53:02.425 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-25 02:53:02.425 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2019-11-25 02:53:02.640 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
+ echo 'Instantiating smart contract on mychannel'
Instantiating smart contract on mychannel
+ docker exec -e CORE_PEER_LOCALMSPID=Org1MSP -e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp cli peer chaincode instantiate -o orderer.example.com:7050 -C mychannel -n fabcar -l golang -v 1.0 -c '{"Args":[]}' -P 'AND('\''Org1MSP.member'\'','\''Org2MSP.member'\'')' --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 --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
2019-11-25 02:53:02.821 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2019-11-25 02:53:02.821 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
+ echo 'Waiting for instantiation request to be committed ...'
Waiting for instantiation request to be committed ...
+ sleep 10
+ echo 'Submitting initLedger transaction to smart contract on mychannel'
Submitting initLedger transaction to smart contract on mychannel
+ echo 'The transaction is sent to the two peers with the chaincode installed (peer0.org1.example.com and peer0.org2.example.com) so that chaincode is built before receiving the following requests'
The transaction is sent to the two peers with the chaincode installed (peer0.org1.example.com and peer0.org2.example.com) so that chaincode is built before receiving the following requests
+ docker exec -e CORE_PEER_LOCALMSPID=Org1MSP -e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp cli peer chaincode invoke -o orderer.example.com:7050 -C mychannel -n fabcar -c '{"function":"initLedger","Args":[]}' --waitForEvent --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 --peerAddresses peer0.org1.example.com:7051 --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt
2019-11-25 02:53:40.438 UTC [chaincodeCmd] ClientWait -> INFO 001 txid [cfcebfbeb43744f277546a0a20a03b7e733ff7aa711032e4dee4b54f5dde04b0] committed with status (VALID) at peer0.org2.example.com:9051
2019-11-25 02:53:40.443 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [cfcebfbeb43744f277546a0a20a03b7e733ff7aa711032e4dee4b54f5dde04b0] committed with status (VALID) at peer0.org1.example.com:7051
2019-11-25 02:53:40.445 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 003 Chaincode invoke successful. result: status:200
+ set +x