Hyperledger Fabric:无法调用chainecode_example02中的chaincode吗?

时间:2019-01-01 17:09:58

标签: hyperledger-fabric hyperledger

我有自己的网络,并尝试按照第一个网络示例使用chaincode_example02 chaincode对其进行测试。当涉及到我的shellscipt中的chaincodeInvoke时,控制台将显示

Sending invoke transaction on peer0.bank peer0.caseManager...
--tlsRootCertFiles
 --peerAddresses peer0.bank.snts.com:7051 --tlsRootCertFiles
--tlsRootCertFiles
 --peerAddresses peer0.bank.snts.com:7051 --tlsRootCertFiles --peerAddresses peer0.caseManager.snts.com:7051 --tlsRootCertFiles
+ peer chaincode invoke -o orderer.snts.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/snts.com/orderers/orderer.snts.com/msp/tlscacerts/tlsca.snts.com-cert.pem -C sntschannel -n mycc --peerAddresses peer0.bank.snts.com:7051 --tlsRootCertFiles --peerAddresses peer0.caseManager.snts.com:7051 --tlsRootCertFiles -c '{"Args":["invoke","a","b","10"]}'
+ res=1
+ set +x
2019-01-01 16:38:40.670 UTC [chaincodeCmd] validatePeerConnectionParameters -> WARN 001 received more TLS root cert files (2) than peer addresses (1)
Error: error validating peer connection parameters: number of peer addresses (1) does not match the number of TLS root cert files (2)
!!!!!!!!!!!!!!! Invoke execution on peer0.bank peer0.caseManager failed  !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========

银行有2个同行,caseManager有3个。什么会导致此问题?在第一个网络示例中,两个组织都有2个对等方,并且运行良好。有人可以帮忙吗?谢谢。

4 个答案:

答案 0 :(得分:1)

在您的请求中,您使用了--tlsRootCertFiles标志,但未指定任何路径?您是在外部设置吗?如果没有尝试像

一样指定
  

-tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt

答案 1 :(得分:0)

问题在于获取TLSINFO的方式。 下面的命令在utils.sh文件中使用,其中提到了TLSCert文件。您需要根据需要对其进行修改。

TLSINFO=$(eval echo "--tlsRootCertFiles \$PEER$1_Org$2_CA")

答案 2 :(得分:0)

您需要修改全局变量,以便它们是通用的。

有必要在 utils.sh 文件的 setOrderererGlobals()方法中进行更改:

setGlobals() {
  PEER=$1
  ORG=$2


  ### ADD THESES LINES !!! ###
CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org$ORG.supplychainnet.ch/peers/peer$PEER.org$ORG.supplychainnet.ch/tls/ca.crt

  CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org$ORG.supplychainnet.ch/users/Admin\@org$ORG.supplychainnet.ch/msp
  ### ADD THESES LINES !!! ###

if [ $ORG -eq 1 ]; then
    CORE_PEER_LOCALMSPID="Org1MSP"

   ### COMMENT THESES LINES !!! ###
    #CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG1_CA
    #CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.supplychainnet.ch/users/Admin\@org1.supplychainnet.ch/msp
   ### COMMENT THESES LINES !!! ###

    if [ $PEER -eq 0 ]; then
      CORE_PEER_ADDRESS=peer0.org1.supplychainnet.ch:7051
    else
      CORE_PEER_ADDRESS=peer1.org1.supplychainnet.ch:8051
    fi
  else
    echo "================== ERROR !!! ORG Unknown =================="
  fi


因此,每个对等方的环境路径将自动用数字$ PEER和$ ORG更新,而不是检索文件顶部定义的全局PEERx_ORGy_CA路径。

答案 3 :(得分:-1)

为--tlsRootCertFiles中的相应对等体传递ca.crt文件路径

尝试一下,就可以了

docker exec -it cli bash

对等链代码调用-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 testchannel -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:7051 --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“,” 20“]}'