分析Fabric示例网络./byfn.sh up 的输出

Starting for channel ‘mychannel’ with CLI timeout of ‘10’ seconds and CLI delay of ‘3’ seconds
Continue? [Y/n] y
////////// byfn.sh line:119 /////////////////////////////////////////////////////
////////// 检查版本 //////////////////////////////////////////////////////
proceeding …
LOCAL_VERSION=2.0.0
DOCKER_IMAGE_VERSION=2.0.0
////////// byfn.sh line:297 generateCerts ///////////////////////////////////
////////// 如果存在目录crypto-config,则删除之 ////////////////////////////
/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/…/bin/cryptogen

##########################################################

Generate certificates using cryptogen tool

##########################################################

////////// 调用cryptogen ///////////////////////////////////
////////// 在当前目录下创建子目录crypto-configls,分层生成各成员的公私钥 /////////
////////// crypto-config.yaml描述各成员构成 //////////////////////////////

  • cryptogen generate --config=./crypto-config.yaml
    org1.example.com
    org2.example.com
  • res=0
  • set +x

Generate CCP files for Org1 and Org2
////////// byfn.sh line:321 调用ccp-generate.sh ///////////////////////
///////// ccp-generate.sh用ccp-template.json,ccp-template.yaml为模板,生成4个文件 /////
////////// connection-org1.json,connection-org1.yaml ////////////
////////// connection-org2.json, connection-org2.yaml ////////////
///////// 用于设置组织的各节点端口, 公钥证书 /////////////
///////// 如果有3个或更多组织,需修改ccp-generate.sh ////////
///////// 在byfn.sh里并没有用到上述产生的4个文件 ////////
/root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/…/bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
////////// byfn.sh line:375 ///////////////////////
////////// configtxgen产生创世纪块genesis.block,用到配置文件configtx.yaml ///////
//////// SampleMultiNodeEtcdRaft:为Raft排序服务创建创世纪块,在configtx.yaml中定义///
//////// configtx.yaml定义网络参数,例如背书策略,打包区块的时间,区块大小等 ///////
//////// channelID指定系统通道的ID /////////////////////
//////// configtx.yaml定义了不少参数,需要单独描述 ////////////

  • configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
    2020-04-10 08:39:41.348 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-10 08:39:41.375 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
    2020-04-10 08:39:41.375 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:“500ms” election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
    2020-04-10 08:39:41.375 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
    2020-04-10 08:39:41.377 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
    2020-04-10 08:39:41.377 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block
  • res=0
  • set +x

#################################################################

Generating channel configuration transaction ‘channel.tx’

#################################################################
////////// configtxgen产生通道channel.tx,用到配置文件configtx.yaml ///////
////////// TwoOrgsChannel:在configtx.yaml定义,定义通道的共识、容量等 ////////////////
//////// channelID指定通道的ID,不是系统通道 /////////////////////

  • configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
    2020-04-10 08:39:41.406 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-10 08:39:41.434 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
    2020-04-10 08:39:41.434 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
    2020-04-10 08:39:41.436 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx
  • res=0
  • set +x

#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
////////// configtxgen设置组织1的锚节点,用到配置文件configtx.yaml ///////
////////// 产生文件Org1MSPanchors.tx ////////////////

  • configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
    2020-04-10 08:39:41.473 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-10 08:39:41.500 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
    2020-04-10 08:39:41.500 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
    2020-04-10 08:39:41.502 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
  • res=0
  • set +x

#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
////////// configtxgen设置组织2的锚节点,用到配置文件configtx.yaml ///////
////////// 产生文件Org2MSPanchors.tx ////////////////

  • configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
    2020-04-10 08:39:41.534 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
    2020-04-10 08:39:41.565 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /root/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
    2020-04-10 08:39:41.565 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
    2020-04-10 08:39:41.567 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
  • res=0
  • set +x
    ////// configtxgen主要用于创建创世纪区块、通道配置、锚节点配置 ///////
    ///// 完成上述步骤后,在channel-artivacts目录下生成4个文件 //////
    ///// channel.tx genesis.block Org1MSPanchors.tx Org2MSPanchors.tx ///////

////////// byfn.sh line:167 ,执行如下命令,启动各节点的docker ///////////////////////
///// IMAGE_TAG=latest /////////////////////////////////
///// docker-compose -f docker-compose-cli.yaml -f docker-compose-etcdraft2.yaml up -d //
///// docker-compose-etcdraft2.yaml启动4个order(order2~order5)节点的docker /////
///// docker-compose-cli.yaml启动6个节点 (order,4个peer,cli)节点的docker /////
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 volume “net_orderer2.example.com” with default driver
Creating volume “net_orderer3.example.com” with default driver
Creating volume “net_orderer4.example.com” with default driver
Creating volume “net_orderer5.example.com” with default driver
Creating orderer.example.com … done
Creating peer1.org2.example.com … done
Creating orderer4.example.com … done
Creating orderer5.example.com … done
Creating peer0.org1.example.com … done
Creating peer1.org1.example.com … done
Creating peer0.org2.example.com … done
Creating orderer3.example.com … done
Creating orderer2.example.com … done
Creating cli … done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
83c79cc4449b hyperledger/fabric-tools:latest “/bin/bash” 3 seconds ago Up Less than a second cli
b252e866db77 hyperledger/fabric-orderer:latest “orderer” 8 seconds ago Up 2 seconds 7050/tcp, 0.0.0.0:8050->8050/tcp orderer2.example.com
a4593529e3c4 hyperledger/fabric-peer:latest “peer node start” 8 seconds ago Up 3 seconds 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com
da8fc277ffc4 hyperledger/fabric-peer:latest “peer node start” 8 seconds ago Up 3 seconds 0.0.0.0:7051->7051/tcp peer0.org1.example.com
1f2df772275e hyperledger/fabric-orderer:latest “orderer” 8 seconds ago Up 2 seconds 7050/tcp, 0.0.0.0:9050->9050/tcp orderer3.example.com
523cd6e05c01 hyperledger/fabric-orderer:latest “orderer” 8 seconds ago Up 3 seconds 7050/tcp, 0.0.0.0:11050->11050/tcp orderer5.example.com
1dbae684457c hyperledger/fabric-peer:latest “peer node start” 8 seconds ago Up 2 seconds 7051/tcp, 0.0.0.0:8051->8051/tcp peer1.org1.example.com
387057e05649 hyperledger/fabric-orderer:latest “orderer” 8 seconds ago Up 3 seconds 7050/tcp, 0.0.0.0:10050->10050/tcp orderer4.example.com
bb17140ee7d6 hyperledger/fabric-peer:latest “peer node start” 8 seconds ago Up 2 seconds 7051/tcp, 0.0.0.0:10051->10051/tcp peer1.org2.example.com
f422e2d45ee5 hyperledger/fabric-orderer:latest “orderer” 8 seconds ago Up 3 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
c9bea8330020 hyperledger/fabric-tools:amd64-1.4.2 “//bin/bash -c 'FABR…” 16 minutes ago Exited (0) 16 minutes ago heuristic_euler
b1fa5fd87acc hyperledger/fabric-tools:amd64-1.4.2 “//bin/bash -c 'FABR…” 16 minutes ago Exited (0) 16 minutes ago strange_mahavira
f09fe7b6e68c bf68857e10c3 “/bin/sh -c 'bash /t…” 17 minutes ago Exited (1) 16 minutes ago cocky_lalande
7d23774ee827 515ff2fd27cc “/bin/sh -c 'bash /t…” 25 minutes ago Exited (1) 23 minutes ago hopeful_raman
9cd87922b2ed hyperledger/fabric-tools:amd64-1.4.2 “//bin/bash -c 'FABR…” 25 minutes ago Exited (0) 25 minutes ago dreamy_shannon
b707ff006624 hyperledger/fabric-tools:amd64-1.4.2 “//bin/bash -c 'FABR…” 25 minutes ago Exited (0) 25 minutes ago quirky_shannon
953e091b9583 98ff39fde1c7 “/bin/sh -c 'bash /t…” 33 minutes ago Exited (1) 25 minutes ago cocky_moore
a2789aa5ac5b hyperledger/fabric-tools:amd64-1.4.2 “//bin/bash -c 'FABR…” 3 days ago Exited (0) 3 days ago quizzical_thompson
667f70baabe0 hyperledger/fabric-tools:amd64-1.4.2 “//bin/bash -c 'FABR…” 3 days ago Exited (0) 3 days ago charming_lichterman
805216a77308 1d016c34e9f6 “/bin/sh -c 'bash /t…” 3 days ago Exited (1) 3 days ago nifty_wiles
b97772fe2542 fa953080b404 “/bin/sh -c 'bash /t…” 3 days ago Exited (1) 3 days ago optimistic_jepsen
Sleeping 15s to allow Raft cluster to complete booting
Vendoring Go dependencies …
~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/abstore/go ~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network
~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/first-network
Finished vendoring Go dependencies

////////// byfn.sh line:186 ///////////////////////
////////// 到这里时,共启动了10个docker(4 peers, 5 orderers,1 cli ) //////////////
////////// 下面将在cli docker里执行脚本 /////////////////////////////////////
////////// docker exec cli scripts/script.sh mychannel 3 go 10 false ///////////////
///////// script.sh在一个单独的docker里设置网络(例如将节点添加到通道中) /////
//////// script.sh还将在peer节点上安装、测试链码 ////////////////////////////////
//////// script.sh完成后,将新启动3个docker,与链码有关 /////////////////////


/ | | | / \ | _ \ | |
_
\ | | / _ \ | |
) | | |
) | | | / ___ \ | _ < | |
|
/ || // _\ || _\ |_|

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
    2020-04-10 00:40:05.924 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-10 00:40:05.945 UTC [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND}
    2020-04-10 00:40:05.948 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
    2020-04-10 00:40:06.150 UTC [cli.common] readBlock -> INFO 004 Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-10 00:40:06.153 UTC [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized
    2020-04-10 00:40:06.358 UTC [cli.common] readBlock -> INFO 006 Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-10 00:40:06.367 UTC [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized
    2020-04-10 00:40:06.571 UTC [cli.common] readBlock -> INFO 008 Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-10 00:40:06.581 UTC [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized
    2020-04-10 00:40:06.784 UTC [cli.common] readBlock -> INFO 00a Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-10 00:40:06.794 UTC [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized
    2020-04-10 00:40:06.999 UTC [cli.common] readBlock -> INFO 00c Expect block, but got status: &{SERVICE_UNAVAILABLE}
    2020-04-10 00:40:07.010 UTC [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized
    2020-04-10 00:40:07.216 UTC [cli.common] readBlock -> INFO 00e Received block: 0
    ===================== Channel ‘mychannel’ created =====================

Having all peers join the channel…

  • peer channel join -b mychannel.block

  • res=0

  • set +x
    2020-04-10 00:40:07.298 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-10 00:40:07.343 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
    2020-04-10 00:40:10.453 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-10 00:40:10.481 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
    2020-04-10 00:40:13.580 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-10 00:40:13.607 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
    2020-04-10 00:40:16.713 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-10 00:40:16.740 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
    2020-04-10 00:40:19.846 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-10 00:40:19.862 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
    2020-04-10 00:40:22.952 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
    2020-04-10 00:40:22.967 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
    ===================== Anchor peers updated for org ‘Org2MSP’ on channel ‘mychannel’ =====================

  • peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label mycc_1

  • res=0

  • set +x
    ===================== Chaincode is packaged on peer0.org1 =====================

Installing chaincode on peer0.org1…

  • peer lifecycle chaincode install mycc.tar.gz
  • res=0
  • set +x
    2020-04-10 00:40:45.888 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:
    2020-04-10 00:40:45.888 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3
    ===================== Chaincode is installed on peer0.org1 =====================

Install chaincode on peer0.org2…

  • peer lifecycle chaincode install mycc.tar.gz

  • res=0

  • set +x
    2020-04-10 00:40:57.744 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:
    2020-04-10 00:40:57.744 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3
    ===================== Chaincode is installed on peer0.org2 =====================

  • peer lifecycle chaincode queryinstalled

  • res=0

  • set +x
    Installed chaincodes on peer:
    Package ID: mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3, Label: mycc_1
    PackageID is mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3
    ===================== Query installed successful on peer0.org1 on channel =====================

  • peer lifecycle chaincode approveformyorg --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 --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3 --sequence 1 --waitForEvent

  • set +x
    2020-04-10 00:40:57.905 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
    2020-04-10 00:40:59.978 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [a503f15489e81e78918bc91c6e333f8f9a88f2671341ba6fe6f489514a3a5996] committed with status (VALID) at
    ===================== Chaincode definition approved on peer0.org1 on channel ‘mychannel’ =====================

===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel ‘mychannel’… =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org1 …3 secs

  • peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
  • res=0
  • set +x

{
“approvals”: {
“Org1MSP”: true,
“Org2MSP”: false
}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel ‘mychannel’ =====================
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel ‘mychannel’… =====================

  • peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
    Attempting to check the commit readiness of the chaincode definition on peer0.org2 …3 secs
  • res=0
  • set +x

{
“approvals”: {
“Org1MSP”: true,
“Org2MSP”: false
}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel ‘mychannel’ =====================

  • peer lifecycle chaincode approveformyorg --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 --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3 --sequence 1 --waitForEvent
  • set +x
    2020-04-10 00:41:06.289 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
    2020-04-10 00:41:08.361 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [a1881a3f10ad237d78c27871fba0701ebcb14cfa2312566515012dc7030d084b] committed with status (VALID) at
    ===================== Chaincode definition approved on peer0.org2 on channel ‘mychannel’ =====================

===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel ‘mychannel’… =====================

  • peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
    Attempting to check the commit readiness of the chaincode definition on peer0.org1 …3 secs
  • res=0
  • set +x

{
“approvals”: {
“Org1MSP”: true,
“Org2MSP”: true
}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel ‘mychannel’ =====================
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel ‘mychannel’… =====================
Attempting to check the commit readiness of the chaincode definition on peer0.org2 …3 secs

  • peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
  • res=0
  • set +x

{
“approvals”: {
“Org1MSP”: true,
“Org2MSP”: true
}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel ‘mychannel’ =====================

  • peer lifecycle chaincode commit -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 --channelID mychannel --name 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 --version 1 --sequence 1 --init-required
  • res=0
  • set +x
    2020-04-10 00:41:16.996 UTC [chaincodeCmd] ClientWait -> INFO 001 txid [31e1703493701adbda39d31f8ce3b4aea18f07f120c9b056fd3034530c8047d4] committed with status (VALID) at peer0.org2.example.com:9051
    2020-04-10 00:41:16.997 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [31e1703493701adbda39d31f8ce3b4aea18f07f120c9b056fd3034530c8047d4] committed with status (VALID) at peer0.org1.example.com:7051
    ===================== Chaincode definition committed on channel ‘mychannel’ =====================

===================== Querying chaincode definition on peer0.org1 on channel ‘mychannel’… =====================
Attempting to Query committed status on peer0.org1 …3 secs

  • peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
  • res=0
  • set +x

Committed chaincode definition for chaincode ‘mycc’ on channel ‘mychannel’:
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org1 on channel ‘mychannel’ =====================
===================== Querying chaincode definition on peer0.org2 on channel ‘mychannel’… =====================
Attempting to Query committed status on peer0.org2 …3 secs

  • peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
  • res=0
  • set +x

Committed chaincode definition for chaincode ‘mycc’ on channel ‘mychannel’:
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org2 on channel ‘mychannel’ =====================

  • 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 --isInit -c ‘{“Args”:[“Init”,“a”,“100”,“b”,“100”]}’
  • res=0
  • set +x
    2020-04-10 00:41:23.395 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
    ===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel ‘mychannel’ =====================

Querying chaincode on peer0.org1…
===================== Querying on peer0.org1 on channel ‘mychannel’… =====================
Attempting to Query peer0.org1 …3 secs

  • peer chaincode query -C mychannel -n mycc -c ‘{“Args”:[“query”,“a”]}’
  • res=0
  • set +x

100
===================== Query successful on peer0.org1 on channel ‘mychannel’ =====================
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
    2020-04-10 00:41:26.606 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200
    ===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel ‘mychannel’ =====================

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

90
===================== Query successful on peer0.org1 on channel ‘mychannel’ =====================
Installing chaincode on peer1.org2…

  • peer lifecycle chaincode install mycc.tar.gz
  • res=0
  • set +x
    2020-04-10 00:41:40.837 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response:
    2020-04-10 00:41:40.837 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:4622fb602aa60c6368716a70474dc9d9ba2776200f70eccca07a4df4360eaff3
    ===================== 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 ===========


| | | \ | | | _ \
| | | | | | | | |
| |
| |\ | | |
| |
|_____| |
| _| |____/

//// 完成上述步骤后,将产生一些区块 ///////////
//// docker exec cli peer channel getinfo -c mychannel 获取指定通道上的区块信息
2020-04-11 01:59:17.429 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Blockchain info: {“height”:8,“currentBlockHash”:“1A+7SUu4crYK6eprW9ZBmmkSvHISCMiSBA2O5RnfRtE=”,“previousBlockHash”:“5rxU3ntHIEtbKIfUT58lkSQ5NvLGD1DuXAQ39lbF8NQ=”}

//// docker exec cli peer channel fetch 7 -c mychannel
//// 获取指定高度(区块号)的区块,存储在docker里
2020-04-11 02:01:10.668 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-04-11 02:01:10.670 UTC [cli.common] readBlock -> INFO 002 Received block: 7

//// docker cp cli:/opt/gopath/src/github.com/hyperledger/fabric/peer/mychannel_7.block .
//// 从docker里复制区块7的文件到本地
//// configtxgen -inspectBlock mychannel_7.block 将区块文件转换成json格式

你可能感兴趣的:(Fabric)