我在peer和couchdb容器中设置了数据持久性,并在cli容器中的peer0 Org1上手动运行带有marbles02链代码的命令(命令行在docker-compose-cli.yaml中注释)问题。弹珠是创建的,我可以从peer0 Org1和peer0 Org2查询它们。但是,当我在peer0 Org2上创建弹珠时,似乎initMarble函数可以正常工作,但大理石并没有真正创建。它在couchdb中不存在,我无法使用peer0 Org1或peer0 Org2上的链代码读取它。
如何在peer0 Org2上使用marbles02链码创建弹珠?谢谢!
Ubuntu版本:
Distributor ID: Ubuntu
Description: Ubuntu 17.10
Release: 17.10
Codename: artful
Hyperledger Fabric版本:
x86_64-1.1.0-preview
以下所有操作都是通过“first-network”(byfn.sh)示例完成的:
配置更改:
在docker-compose-base.yaml的volumes部分中添加以下行以获取对等容器数据持久性
for peer0.org1.example.com:
- ../persist-data/peer0org1:/var/hyperledger/production
for peer1.org1.example.com:
- ../persist-data/peer1org1:/var/hyperledger/production
for peer0.org2.example.com:
- ../persist-data/peer0org2:/var/hyperledger/production
for peer1.org2.example.com:
- ../persist-data/peer1org2:/var/hyperledger/production
在docker-compose-couch.yaml的volumes部分中为couchdb容器数据持久性添加了以下行
for couchdb0:
- ./persist-data/couchdb0:/opt/couchdb/data
for couchdb1:
- ./persist-data/couchdb1:/opt/couchdb/data
for couchdb2:
- ./persist-data/couchdb2:/opt/couchdb/data
for couchdb3:
- ./persist-data/couchdb3:/opt/couchdb/data
我还更改为couchdb端口号,如下所示,以避免与我计算机上安装的couchdb冲突:
for couchdb0:
- "6984:5984"
for couchdb1:
- "7984:5984"
for couchdb2:
- "8984:5984"
for couchdb3:
- "9984:5984"
动作和命令:
cd to the first-network directory
../../bin/cryptogen generate --config=./crypto-config.yaml
export FABRIC_CFG_PATH=$PWD
../../bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block
export CHANNEL_NAME=mychannel && ../../bin/configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
../../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
../../bin/configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP
docker-compose -f docker-compose-cli.yaml -f docker-compose-couch.yaml up -d
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
CORE_PEER_LOCALMSPID="Org1MSP"
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
# enter the cli container and execute the commands in the cli container manually
docker exec -it cli bash
export CHANNEL_NAME=mychannel
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
peer channel join -b mychannel.block
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer channel join -b mychannel.block
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
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org2MSPanchors.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
peer chaincode install -n marbles -v 1.0 -p github.com/chaincode/marbles02/go
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode install -n marbles -v 1.0 -p github.com/chaincode/marbles02/go
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 marbles -v 1.0 -c '{"Args":["init"]}' -P "OR ('Org0MSP.member','Org1MSP.member')"
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 marbles -c '{"Args":["initMarble","marble1","blue","35","tom"]}'
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 marbles -c '{"Args":["initMarble","marble2","red","50","tom"]}'
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 marbles -c '{"Args":["initMarble","marble3","blue","70","tom"]}'
# The output of the 2 following commands on peer0 Org1 is at the bottom
peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["readMarble","marble1"]}'
peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["getMarblesByRange","marble","marble9"]}'
# The output of the 2 following commands on peer0 Org2 is at the bottom
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["readMarble","marble1"]}'
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["getMarblesByRange","marble","marble9"]}'
# The output of the following initMarble command is at the bottom
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer 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 marbles -c '{"Args":["initMarble","marble4","red","40","john"]}'
# The output of the 2 following commands on peer0 Org1 is at the bottom
peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["readMarble","marble1"]}'
peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["getMarblesByRange","marble","marble9"]}'
# The output of the 2 following commands on peer0 Org2 is at the bottom
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["readMarble","marble1"]}'
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["getMarblesByRange","marble","marble9"]}'
在peer0 Org1上输出前两个查询:
root@370bc984a456:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["readMarble","marble1"]}'
2018-01-26 17:51:22.809 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:51:22.809 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:51:22.809 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:51:22.809 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:51:22.809 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:51:22.810 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAE070A6A08031A0C089AD5ADD30510...644D6172626C650A076D6172626C6531
2018-01-26 17:51:22.810 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 4F366060889A2856285FC243DC170DE5EF24C3215156DAAA0CF61EDDE7177988
Query Result: {"color":"blue","docType":"marble","name":"marble1","owner":"tom","size":35}
2018-01-26 17:51:22.834 UTC [main] main -> INFO 008 Exiting.....
root@370bc984a456:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["getMarblesByRange","marble","marble9"]}'
2018-01-26 17:52:21.753 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:52:21.753 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:52:21.753 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:52:21.753 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:52:21.753 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:52:21.754 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAE070A6A08031A0C08D5D5ADD30510...066D6172626C650A076D6172626C6539
2018-01-26 17:52:21.754 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: E03478475574EE33CA10C951A3D4CBC7B5F8FEF2F4C2EDC34C039CF4EFC614AD
Query Result: [{"Key":"marble1", "Record":{"color":"blue","docType":"marble","name":"marble1","owner":"tom","size":35}},{"Key":"marble2", "Record":{"color":"red","docType":"marble","name":"marble2","owner":"tom","size":50}},{"Key":"marble3", "Record":{"color":"blue","docType":"marble","name":"marble3","owner":"tom","size":70}}]
2018-01-26 17:52:21.782 UTC [main] main -> INFO 008 Exiting.....
在peer0 Org2上输出前两个查询:
root@370bc984a456:/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/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["readMarble","marble1"]}'
2018-01-26 17:53:01.507 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:53:01.507 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:53:01.508 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:53:01.508 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:53:01.509 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:53:01.509 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAE070A6A08031A0C08FDD5ADD30510...644D6172626C650A076D6172626C6531
2018-01-26 17:53:01.510 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 1D08C870FDC0BE2CC2BE293ABF18BF1EBB73EDEC47425A132DD303DD222B557E
Query Result: {"color":"blue","docType":"marble","name":"marble1","owner":"tom","size":35}
2018-01-26 17:53:25.592 UTC [main] main -> INFO 008 Exiting.....
root@370bc984a456:/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/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["getMarblesByRange","marble","marble9"]}'
2018-01-26 17:53:39.818 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:53:39.818 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:53:39.818 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:53:39.818 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:53:39.818 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:53:39.818 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAE070A6A08031A0C08A3D6ADD30510...066D6172626C650A076D6172626C6539
2018-01-26 17:53:39.818 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: ACB6855D69BB8609BF5D07997193AC456BE2AACB0E9B9833FEEEA3E1FA944B34
Query Result: [{"Key":"marble1", "Record":{"color":"blue","docType":"marble","name":"marble1","owner":"tom","size":35}},{"Key":"marble2", "Record":{"color":"red","docType":"marble","name":"marble2","owner":"tom","size":50}},{"Key":"marble3", "Record":{"color":"blue","docType":"marble","name":"marble3","owner":"tom","size":70}}]
2018-01-26 17:53:39.859 UTC [main] main -> INFO 008 Exiting.....
在peer0 Org2上输出initMarble(marble4)。没有报告错误,一切看起来都很好:
root@370bc984a456:/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/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer 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 marbles -c '{"Args":["initMarble","marble4","red","40","john"]}'
2018-01-26 17:53:57.895 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:53:57.895 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:53:57.913 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:53:57.913 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:53:57.913 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:53:57.914 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAE070A6A08031A0C08B5D6ADD30510...340A037265640A0234300A046A6F686E
2018-01-26 17:53:57.914 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 22F1EBED19D01BB926BC8333D8E6C20D7CEA98D67E3FBDB32A97C052034A42E0
2018-01-26 17:53:57.946 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0AAE070A6A08031A0C08B5D6ADD30510...963DE13101C543F98E6EB1DAD7504648
2018-01-26 17:53:57.947 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: EE16EB383E3F43FFC29004E899F20D2639463A9F13B592454EB202441112B42A
2018-01-26 17:53:57.979 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> DEBU 00a ESCC invoke result: version:1 response:<status:200 message:"OK" > payload:"\n \035\356\245\202T~!g\217H\243\371\265\212\016t\365|&\032\206\367\352\2240\246\3003\247\236G,\022\303\001\n\253\001\022\027\n\004lscc\022\017\n\r\n\007marbles\022\002\010\003\022\217\001\n\007marbles\022\203\001\n\t\n\007marble4\032\035\n\030\000color~name\000red\000marble4\000\032\001\000\032W\n\007marble4\032L{\"docType\":\"marble\",\"name\":\"marble4\",\"color\":\"red\",\"size\":40,\"owner\":\"john\"}\032\003\010\310\001\"\016\022\007marbles\032\0031.0" endorsement:<endorser:"\n\007Org2MSP\022\222\006-----BEGIN CERTIFICATE-----\nMIICGDCCAb+gAwIBAgIQYknfKWIh8KsyyPE57tFenjAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMi5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMi5leGFtcGxlLmNvbTAeFw0xODAxMjYxNzQxMzJaFw0yODAxMjQxNzQxMzJa\nMFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMR8wHQYDVQQDExZwZWVyMC5vcmcyLmV4YW1wbGUuY29tMFkw\nEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE7SAoZn22uMkwfrDItRK47xRRfkBIZLtN\n2vk1qdTt8IA53g3MjXMkAYeONaJE2BUyfYjhU+ghaZyv153Kzs8EDaNNMEswDgYD\nVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAgQrkMYeoaoiK6\nnRCVankLQpgURiWVC9Av/sxHBo9gBuAwCgYIKoZIzj0EAwIDRwAwRAIgJy2H0bV2\nYh788eAEdSu8qxLTO9wZrXDrjjw7HiOIikoCIE1lP0P1Y18W0HWYQ8iva6CyEQd2\noQIsD5MBLlSjMCEP\n-----END CERTIFICATE-----\n" signature:"0E\002!\000\255\313\361\004=A&\277\270\222\330s\227\014\251\207\324\372\323\321\317\204\026\240\276\312\231\372(\306\367~\002 }\207\333z\0049!WnE\032\2346K\027\364\226=\3411\001\305C\371\216n\261\332\327PFH" >
2018-01-26 17:53:57.979 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 00b Chaincode invoke successful. result: status:200
2018-01-26 17:53:57.979 UTC [main] main -> INFO 00c Exiting.....
在peer0 Org1上输出后两个查询。找不到新的大理石4。它在任何couchdb中都不存在:
root@370bc984a456:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["readMarble","marble1"]}'
2018-01-26 17:54:32.695 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:54:32.695 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:54:32.695 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:54:32.695 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:54:32.696 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:54:32.696 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAE070A6A08031A0C08D8D6ADD30510...644D6172626C650A076D6172626C6531
2018-01-26 17:54:32.696 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: A057F20C69546CB01ED6E9F858E1CD066BC5FC3476F92BC5A5902E44DEA9E68E
Query Result: {"color":"blue","docType":"marble","name":"marble1","owner":"tom","size":35}
2018-01-26 17:54:32.799 UTC [main] main -> INFO 008 Exiting.....
root@370bc984a456:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["getMarblesByRange","marble","marble9"]}'
2018-01-26 17:54:44.238 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:54:44.238 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:54:44.239 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:54:44.239 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:54:44.239 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:54:44.239 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAD070A6908031A0B08E4D6ADD30510...066D6172626C650A076D6172626C6539
2018-01-26 17:54:44.239 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: C2A0ADD3589727D58B7DB1320980CD9F21416B7352E1BFAE8AF35603FB45BE1A
Query Result: [{"Key":"marble1", "Record":{"color":"blue","docType":"marble","name":"marble1","owner":"tom","size":35}},{"Key":"marble2", "Record":{"color":"red","docType":"marble","name":"marble2","owner":"tom","size":50}},{"Key":"marble3", "Record":{"color":"blue","docType":"marble","name":"marble3","owner":"tom","size":70}}]
2018-01-26 17:54:44.278 UTC [main] main -> INFO 008 Exiting.....
在peer0 Org2上输出后两个查询。找不到新的大理石4。它在任何couchdb中都不存在:
root@370bc984a456:/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/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["readMarble","marble1"]}'
2018-01-26 17:54:55.967 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:54:55.967 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:54:55.968 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:54:55.968 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:54:55.968 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:54:55.968 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAE070A6A08031A0C08EFD6ADD30510...644D6172626C650A076D6172626C6531
2018-01-26 17:54:55.968 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: BE24E989B610A67B9ABE249142AA8E986B0BF65F722F850E26E095038529664D
Query Result: {"color":"blue","docType":"marble","name":"marble1","owner":"tom","size":35}
2018-01-26 17:54:56.001 UTC [main] main -> INFO 008 Exiting.....
root@370bc984a456:/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/Admin@org2.example.com/msp CORE_PEER_ADDRESS=peer0.org2.example.com:7051 CORE_PEER_LOCALMSPID="Org2MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt peer chaincode query -C $CHANNEL_NAME -n marbles -c '{"Args":["getMarblesByRange","marble","marble9"]}'
2018-01-26 17:55:05.856 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-01-26 17:55:05.856 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-01-26 17:55:05.856 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 003 Using default escc
2018-01-26 17:55:05.856 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 004 Using default vscc
2018-01-26 17:55:05.856 UTC [chaincodeCmd] getChaincodeSpec -> DEBU 005 java chaincode disabled
2018-01-26 17:55:05.857 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAE070A6A08031A0C08F9D6ADD30510...066D6172626C650A076D6172626C6539
2018-01-26 17:55:05.857 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: B1916904CFD8D2908F9BE2A88986D4B93D299F0647D816A2849A9984F688F81F
Query Result: [{"Key":"marble1", "Record":{"color":"blue","docType":"marble","name":"marble1","owner":"tom","size":35}},{"Key":"marble2", "Record":{"color":"red","docType":"marble","name":"marble2","owner":"tom","size":50}},{"Key":"marble3", "Record":{"color":"blue","docType":"marble","name":"marble3","owner":"tom","size":70}}]
2018-01-26 17:55:05.893 UTC [main] main -> INFO 008 Exiting.....
答案 0 :(得分:1)
这是由我自己的错误造成的。当我实例化链码时,我指定了错误的认可政策:
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 marbles -v 1.0 -c '{"Args":["init"]}' -P "OR ('Org0MSP.member','Org1MSP.member')"
Org0MSP不存在,Org2的Org2MSP不在策略上。因此,交易并没有真正完成。
正确的政策应该是
-P "OR ('Org1MSP.member','Org2MSP.member')"
修复instantiate命令后,一切都在peer0 Org1和peer0 Org2中按预期工作。
但是,为什么没有报告错误或异常?如果您知道布料内部在这种情况下是如何工作的,请提供建议,我将非常感谢您的意见。谢谢!