Hyperledger Fabric 整理体系:
./byfn.sh up
创建网络
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执行了一系列网络构建工作:
- 创建channel,并将所有peers加入channel
- 设定每个org的anchor peer
- intall chaincode到两个anchor peer,实例化其中一个
- query和invoke操作
- instantiateChaincode chaincode到另一个结点,并在其上query
____ _____ _ ____ _____
/ ___| |_ _| / \ | _ \ |_ _|
\___ \ | | / _ \ | |_) | | |
___) | | | / ___ \ | _ < | |
|____/ |_| /_/ \_\ |_| \_\ |_|
Build your first network (BYFN) end-to-end test
# 该命令执行后,会在本地生成一个与应用通道名称同名的初始区块mychannel.block,网络节点只有拥有该文件才可以加入创建的应用通道中。
# 参数说明
# -o orderer节点地址
# -c 要创建的应用通道的名称(必须与在创建应用通道交易配置文件时的通道名称一致)
# -f 创建应用通道时,所使用的应用通道交易配置文件
# --tls 开启TLS验证
# --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 =====================
# 应用通道所包含组织的成员节点加入通道中
# join命令:将本Peer节点加入到应用通道中
# 参数说明:
# -b:指定当前节点要加入/连接到哪个应用通道
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的管理员身份更新锚节点配置
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的管理员身份更新锚节点配置
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生命周期共有五个命令:
# install:将已编写完成的链码安装在网络节点中
# instantiate:对已安装的链码进行实例化
# upgrade:对已有链码进行升级。链码可以在安装后根据具体需求的变化进行升级。
# package:对指定链码进行打包的操作
# signpackage:签名
# 安装链码
# 参数说明
# -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 =====================
# 实例化链码
# 参数说明
# -o:指定Orderer服务节点地址
# --tls:开启TLS验证
# --cafile:指定TLS_CA证书的所在路径
# -n:指定要实例化的链码名称,必须与安装时指定的链码名称相同
# -v:指定要实例化的链码版本号,必须与安装时指定的链码版本号相同
# -C:指定通道名称
# -c:实例化链码时指定的参数
# -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' =====================
# 查询链码
# 参数说明
# -n:指定要调用的链码名称高
# -C:指定通道名称
# -c:指定调用链码时所需要的参数
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' =====================
# 调用链码
# 参数说明
# -o:指定Orderer服务节点地址
# --tls:开启TLS验证
# --cafile:指定TLS_CA证书的所在路径
# -n:指定要实例化的链码名称,必须与安装时指定的链码名称相同
# -v:指定要实例化的链码版本号,必须与安装时指定的链码版本号相同
# -C:指定通道名称
# -c:实例化链码时指定的参数
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
创建网络
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
网友评论