First Network详解
使用cryptogen加密工具为网络链中相应节点的加密文件,以便各节点安全通讯生成证书和密钥(certs and keys)到/opt/gopath/src/github.com/hyperledger/fabric-samples/first-network/crypto-config目录
[root@huangzhenhua first-network]# ../bin/cryptogen generate --config=./crypto-config.yaml
org1.example.com
org2.example.com
configtxgen工具需要使用configtx.yaml配置文件,设置configtx.yaml文件目录为PWD
使用configtxgen工具为共识(orderer)节点生成原始块
[root@huangzhenhua first-network]# export FABRIC_CFG_PATH=$PWD
[root@huangzhenhua first-network]# ../bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
2018-02-06 14:45:05.072 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-02-06 14:45:05.101 CST [common/configtx/tool] doOutputBlock -> INFO 002 Generating genesis block
2018-02-06 14:45:05.104 CST [common/configtx/tool] doOutputBlock -> INFO 003 Writing genesis block
创建通道配置事务--设置CHANNEL_NAME环境变量
创建通道配置事务--创建通道交易配置文件
[root@huangzhenhua first-network]# export CHANNEL_NAME=mychannel
[root@huangzhenhua first-network]# ../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
2018-02-06 14:45:46.644 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-02-06 14:45:46.648 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-02-06 14:45:46.648 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx
创建通道配置事务--创建机构1的通道交易配置文件
[root@huangzhenhua first-network]# ../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
2018-02-06 14:46:03.190 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-02-06 14:46:03.195 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-02-06 14:46:03.196 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
创建通道配置事务--创建机构2的通道交易配置文件
[root@huangzhenhua first-network]# ../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
2018-02-06 14:46:12.802 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-02-06 14:46:12.808 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-02-06 14:46:12.808 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
开启Fabric网络链
[root@huangzhenhua first-network]# CHANNEL_NAME=$CHANNEL_NAME docker-compose -f docker-compose-cli.yaml up -d
Creating peer0.org1.example.com ... done
Creating cli ... done
Creating peer0.org2.example.com ...
Creating peer0.org1.example.com ...
Creating peer1.org2.example.com ...
Creating peer1.org1.example.com ...
Creating cli ...
进入peer节点,默认进入peer0.org1节点(具体配置请看docker-compose-cli.yaml中 environment)
[root@huangzhenhua first-network]# docker exec -it cli bash
设置CHANNEL_NAME环境变量,并创建channel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# export CHANNEL_NAME=mychannel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
2018-02-06 06:47:14.966 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 06:47:14.966 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 06:47:15.106 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-02-06 06:47:15.106 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-02-06 06:47:15.106 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-02-06 06:47:15.106 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-02-06 06:47:15.107 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-02-06 06:47:15.107 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A8C060A074F7267314D53501280062D...53616D706C65436F6E736F727469756D
2018-02-06 06:47:15.107 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 9AD72083789E541ED07EEE0B5B42BD352E0562ECDFF344C15054B18DC556A522
2018-02-06 06:47:15.108 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-02-06 06:47:15.108 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-02-06 06:47:15.108 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-02-06 06:47:15.108 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-02-06 06:47:15.108 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AC3060A1508021A0608F39EE5D30522...1D7C717A4A858303CBF5CE42846764C9
2018-02-06 06:47:15.108 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 236E137C3BE125BFE20E4F84B3A4AB8410D7A039E31A2D52DEE52074D5CCC673
2018-02-06 06:47:15.214 UTC [msp] GetLocalMSP -> DEBU 010 Returning existing local MSP
2018-02-06 06:47:15.215 UTC [msp] GetDefaultSigningIdentity -> DEBU 011 Obtaining default signing identity
2018-02-06 06:47:15.215 UTC [msp] GetLocalMSP -> DEBU 012 Returning existing local MSP
2018-02-06 06:47:15.215 UTC [msp] GetDefaultSigningIdentity -> DEBU 013 Obtaining default signing identity
2018-02-06 06:47:15.215 UTC [msp/identity] Sign -> DEBU 014 Sign: plaintext: 0AC3060A1508021A0608F39EE5D30522...3E5CC8C4DD0C12080A021A0012021A00
2018-02-06 06:47:15.215 UTC [msp/identity] Sign -> DEBU 015 Sign: digest: 893CFAC3DDA13C0ABDEE12BCF2C64E28232385A7AA698C5C6824D540A1ADEF88
2018-02-06 06:47:15.219 UTC [channelCmd] readBlock -> DEBU 016 Got status: &{NOT_FOUND}
2018-02-06 06:47:15.219 UTC [msp] GetLocalMSP -> DEBU 017 Returning existing local MSP
2018-02-06 06:47:15.219 UTC [msp] GetDefaultSigningIdentity -> DEBU 018 Obtaining default signing identity
2018-02-06 06:47:15.226 UTC [channelCmd] InitCmdFactory -> INFO 019 Endorser and orderer connections initialized
2018-02-06 06:47:15.427 UTC [msp] GetLocalMSP -> DEBU 01a Returning existing local MSP
2018-02-06 06:47:15.427 UTC [msp] GetDefaultSigningIdentity -> DEBU 01b Obtaining default signing identity
2018-02-06 06:47:15.427 UTC [msp] GetLocalMSP -> DEBU 01c Returning existing local MSP
2018-02-06 06:47:15.427 UTC [msp] GetDefaultSigningIdentity -> DEBU 01d Obtaining default signing identity
2018-02-06 06:47:15.427 UTC [msp/identity] Sign -> DEBU 01e Sign: plaintext: 0AC3060A1508021A0608F39EE5D30522...D0F21658B62012080A021A0012021A00
2018-02-06 06:47:15.427 UTC [msp/identity] Sign -> DEBU 01f Sign: digest: A97157E14A204CFC554D01E20D5B0895A591390A9A2FAAF8B397B3ACE6618AC1
2018-02-06 06:47:15.431 UTC [channelCmd] readBlock -> DEBU 020 Received block: 0
2018-02-06 06:47:15.431 UTC [main] main -> INFO 021 Exiting.....
把当前peer0.org1节点加入到mychannel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel join -b mychannel.block
2018-02-06 06:47:30.137 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 06:47:30.137 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 06:47:30.143 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-02-06 06:47:30.144 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A89070A5B08011A0B08829FE5D30510...C628DDFB37031A080A000A000A000A00
2018-02-06 06:47:30.144 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 8F9FECE4557FA715E29AEBD658CFE7254F87844C34EE3E5EE68D8D0E199BF5A6
2018-02-06 06:47:30.233 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2018-02-06 06:47:30.233 UTC [main] main -> INFO 007 Exiting.....
切换到peer1.org1节点,把peer1.org1节点加入到mychannel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_ADDRESS=peer1.org1.example.com:7051
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_LOCALMSPID="Org1MSP"
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel join -b mychannel.block
2018-02-06 06:49:43.825 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 06:49:43.825 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 06:49:43.832 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-02-06 06:49:43.833 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A8A070A5C08011A0C0887A0E5D30510...C628DDFB37031A080A000A000A000A00
2018-02-06 06:49:43.833 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: B3A936C7AEB981BE693173F6F54B6FD118DBE36FB10B25B182CDDC84367A3944
2018-02-06 06:49:43.904 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2018-02-06 06:49:43.904 UTC [main] main -> INFO 007 Exiting.....
切换到peer0.org2节点,把peer0.org2节点加入到mychannel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_ADDRESS=peer0.org2.example.com:7051
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_LOCALMSPID="Org2MSP"
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel join -b mychannel.block
2018-02-06 06:50:33.968 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 06:50:33.968 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 06:50:33.975 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-02-06 06:50:33.976 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A8A070A5C08011A0C08B9A0E5D30510...C628DDFB37031A080A000A000A000A00
2018-02-06 06:50:33.976 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 891596EC1356CF8F41E5B058412CAB65A6E5979D5678EC9E63C18EE7E29EA1BB
2018-02-06 06:50:34.041 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2018-02-06 06:50:34.041 UTC [main] main -> INFO 007 Exiting.....
切换到peer1.org2节点,把peer1.org2节点加入到mychannel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_ADDRESS=peer1.org2.example.com:7051
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_LOCALMSPID="Org2MSP"
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel join -b mychannel.block
2018-02-06 06:52:13.459 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 06:52:13.459 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 06:52:13.466 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-02-06 06:52:13.467 UTC [msp/identity] Sign -> DEBU 004 Sign: plaintext: 0A8A070A5C08011A0C089DA1E5D30510...C628DDFB37031A080A000A000A000A00
2018-02-06 06:52:13.467 UTC [msp/identity] Sign -> DEBU 005 Sign: digest: 8D53819877FF1392DDD0AFE99D6DDFCA0123689745294EF199E3A84C4547E0D5
2018-02-06 06:52:13.562 UTC [channelCmd] executeJoin -> INFO 006 Peer joined the channel!
2018-02-06 06:52:13.562 UTC [main] main -> INFO 007 Exiting.....
切换到peer0.org1节点,更新channel配置
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_ADDRESS=peer0.org1.example.com:7051
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_LOCALMSPID="Org1MSP"
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# export CHANNEL_NAME=mychannel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
2018-02-06 06:53:08.935 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 06:53:08.935 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 06:53:08.941 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-02-06 06:53:08.942 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-02-06 06:53:08.942 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-02-06 06:53:08.942 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-02-06 06:53:08.942 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-02-06 06:53:08.942 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A8C060A074F7267314D53501280062D...2A0641646D696E732A0641646D696E73
2018-02-06 06:53:08.942 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: AE5CDDF6669124CAB3B67DF83F4F2E1C28B23C99A3A0722BBA57A1262766D133
2018-02-06 06:53:08.942 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-02-06 06:53:08.942 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-02-06 06:53:08.942 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-02-06 06:53:08.942 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-02-06 06:53:08.942 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AC3060A1508021A0608D4A1E5D30522...7C2D3CF446B7C91A97D40C7CA2F2519F
2018-02-06 06:53:08.942 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 65C1FF4C6240DE3319969D66C83EA99649AA94430A16C62DF9BFC51882C13909
2018-02-06 06:53:08.989 UTC [main] main -> INFO 010 Exiting.....
切换到peer0.org2节点,更新channel配置
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_ADDRESS=peer0.org2.example.com:7051
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_LOCALMSPID="Org2MSP"
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# export CHANNEL_NAME=mychannel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
2018-02-06 06:54:04.625 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 06:54:04.626 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 06:54:04.631 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-02-06 06:54:04.632 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-02-06 06:54:04.632 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-02-06 06:54:04.632 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-02-06 06:54:04.632 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-02-06 06:54:04.632 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A8C060A074F7267324D53501280062D...2A0641646D696E732A0641646D696E73
2018-02-06 06:54:04.632 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 0B270A936C10C9FF19A487CA81E2770E8C2D88D7CDC43D1F578AF12390577293
2018-02-06 06:54:04.632 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-02-06 06:54:04.632 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-02-06 06:54:04.632 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-02-06 06:54:04.632 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-02-06 06:54:04.632 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AC3060A1508021A06088CA2E5D30522...C8870427F5252746B52F8323A6D26ACC
2018-02-06 06:54:04.632 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: BB574D22DEC28338299480B6FD5338EB955ED51EE10D723C50F6BF633A5C37CD
2018-02-06 06:54:04.685 UTC [main] main -> INFO 010 Exiting.....
切换到peer0.org1节点,安装chaincode
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_ADDRESS=peer0.org1.example.com:7051
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_LOCALMSPID="Org1MSP"
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2018-02-06 08:12:41.404 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 08:12:41.404 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 08:12:41.407 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-02-06 08:12:41.407 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-02-06 08:12:41.811 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2018-02-06 08:12:42.226 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2018-02-06 08:12:42.227 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-02-06 08:12:42.227 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-02-06 08:12:42.227 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2018-02-06 08:12:42.227 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2018-02-06 08:12:42.237 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A89070A5B08031A0B08FAC6E5D30510...5F74FD270000FFFFCEF44F9B002C0000
2018-02-06 08:12:42.237 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: A13CFFDE86AD8329BF886FC2F8DCC71334A83ED6FF792B5C0BFECC6C97A760B9
2018-02-06 08:12:42.243 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:
2018-02-06 08:12:42.243 UTC [main] main -> INFO 00e Exiting.....
切换到peer0.org2节点,安装chaincode
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/[email protected]/msp
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_ADDRESS=peer0.org2.example.com:7051
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# CORE_PEER_LOCALMSPID="Org2MSP"
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2018-02-06 08:13:39.545 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 08:13:39.545 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 08:13:39.545 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-02-06 08:13:39.545 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-02-06 08:13:39.658 UTC [golang-platform] getCodeFromFS -> DEBU 005 getCodeFromFS github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
2018-02-06 08:13:40.085 UTC [golang-platform] func1 -> DEBU 006 Discarding GOROOT package fmt
2018-02-06 08:13:40.085 UTC [golang-platform] func1 -> DEBU 007 Discarding provided package github.com/hyperledger/fabric/core/chaincode/shim
2018-02-06 08:13:40.085 UTC [golang-platform] func1 -> DEBU 008 Discarding provided package github.com/hyperledger/fabric/protos/peer
2018-02-06 08:13:40.085 UTC [golang-platform] func1 -> DEBU 009 Discarding GOROOT package strconv
2018-02-06 08:13:40.085 UTC [golang-platform] GetDeploymentPayload -> DEBU 00a done
2018-02-06 08:13:40.088 UTC [msp/identity] Sign -> DEBU 00b Sign: plaintext: 0A89070A5B08031A0B08B4C7E5D30510...5F74FD270000FFFFCEF44F9B002C0000
2018-02-06 08:13:40.088 UTC [msp/identity] Sign -> DEBU 00c Sign: digest: 9E63F3BDD18D2577E1B887AC2B291DF209471710BE0FFD7264FC93996C258DDD
2018-02-06 08:13:40.093 UTC [chaincodeCmd] install -> DEBU 00d Installed remotely response:
2018-02-06 08:13:40.093 UTC [main] main -> INFO 00e Exiting.....
在peer0.org2节点,初始化a、b账号数据
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# export CHANNEL_NAME=mychannel
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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.member','Org2MSP.member')"
2018-02-06 08:13:59.785 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 08:13:59.785 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 08:13:59.789 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-02-06 08:13:59.789 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-02-06 08:13:59.853 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A95070A6708031A0C08C7C7E5D30510...324D53500A04657363630A0476736363
2018-02-06 08:13:59.853 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: B59FB2BB66594C33A42A943473996086F2A9D068CB6E0006FF9443E28D73C443
2018-02-06 08:14:25.336 UTC [msp/identity] Sign -> DEBU 007 Sign: plaintext: 0A95070A6708031A0C08C7C7E5D30510...8DD431C812A21D2AD9921BB5FE6E50D1
2018-02-06 08:14:25.337 UTC [msp/identity] Sign -> DEBU 008 Sign: digest: C5205C593D16772847F77A82BF098326B311522E93F28F16CC66B5642DDF519E
2018-02-06 08:14:25.340 UTC [main] main -> INFO 009 Exiting.....
在peer0.org2节点,查询a账号数据
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
2018-02-06 08:14:35.049 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 08:14:35.049 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 08:14:35.049 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-02-06 08:14:35.049 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-02-06 08:14:35.050 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A94070A6608031A0B08EBC7E5D30510...6D7963631A0A0A0571756572790A0161
2018-02-06 08:14:35.050 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: D343D33C9CCCD99E2F9FCF431D3FE1231A7756C06E3B5F86F4D444B62ED3F862
Query Result: 100
2018-02-06 08:14:35.060 UTC [main] main -> INFO 007 Exiting.....
在peer0.org2节点,模拟a向b转账
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode invoke -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 -c '{"Args":["invoke","a","b","10"]}'
2018-02-06 08:14:43.457 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 08:14:43.457 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 08:14:43.461 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-02-06 08:14:43.461 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-02-06 08:14:43.461 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A95070A6708031A0C08F3C7E5D30510...696E766F6B650A01610A01620A023130
2018-02-06 08:14:43.461 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 6F13CB19FF358AB761B4FFD9D5D3E77F27A3827F617C3A6B0D9757FE3BE4543A
2018-02-06 08:14:43.491 UTC [msp/identity] Sign -> DEBU 007 Sign: plaintext: 0A95070A6708031A0C08F3C7E5D30510...55F7E7565D3E680BB879402496ACFC96
2018-02-06 08:14:43.491 UTC [msp/identity] Sign -> DEBU 008 Sign: digest: 7BEFEB5820B013E001D3AF91AD8EA4572071C54C189A3F5C3FC980C5197AD7AD
2018-02-06 08:14:43.508 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 009 ESCC invoke result: version:1 response:
2018-02-06 08:14:43.508 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00a Chaincode invoke successful. result: status:200
2018-02-06 08:14:43.508 UTC [main] main -> INFO 00b Exiting.....
在peer0.org2节点,查询a转账后数据
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}'
2018-02-06 08:14:55.633 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-02-06 08:14:55.634 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-02-06 08:14:55.634 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-02-06 08:14:55.634 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-02-06 08:14:55.637 UTC [msp/identity] Sign -> DEBU 005 Sign: plaintext: 0A95070A6708031A0C08FFC7E5D30510...6D7963631A0A0A0571756572790A0161
2018-02-06 08:14:55.638 UTC [msp/identity] Sign -> DEBU 006 Sign: digest: 2772F45D1CF8FCC390D09D4A87D96D687EFEFF8B4144B66CD1D57CB19FEF1EFB
Query Result: 90
2018-02-06 08:14:55.648 UTC [main] main -> INFO 007 Exiting.....
root@5856b4395a0e:/opt/gopath/src/github.com/hyperledger/fabric/peer#exit
exit