首页 > 解决方案 > 调用链码时出错“错误:未知标志:--peerAddresses”Hyperledger Fabric first-network 教程

问题描述

我一直在大致按照http://hyperledger-fabric.readthedocs.io/en/latest/build_network.html#troubleshoot创建我的第一个网络,并执行了涉及安装、实例化、查询链码的步骤。但是,在调用链代码时出现以下错误。

root@5a0be253ef6e:/opt/gopath/src/github.com/hyperledger/fabric/peer# 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 testhimani123456 -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","10"]}'
Error: unknown flag: --peerAddresses
Usage:
  peer chaincode invoke [flags]

Flags:
  -C, --channelID string   The channel on which this command should be executed
  -c, --ctor string        Constructor message for the chaincode in JSON format (default "{}")
  -n, --name string        Name of the chaincode

Global Flags:
      --cafile string                       Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
      --certfile string                     Path to file containing PEM-encoded X509 public key to use for mutual TLS communication with the orderer endpoint
      --clientauth                          Use mutual TLS when communicating with the orderer endpoint
      --keyfile string                      Path to file containing PEM-encoded private key to use for mutual TLS communication with the orderer endpoint
      --logging-level string                Default logging level and overrides, see core.yaml for full syntax
  -o, --orderer string                      Ordering service endpoint
      --ordererTLSHostnameOverride string   The hostname override to use when validating the TLS connection to the orderer.
      --tls                                 Use TLS when communicating with the orderer endpoint
      --transient string                    Transient map of arguments in JSON encoding
  -v, --version                             Display current version of fabric peer server

我忽略了有关环境变量的部分。在此处输入图像描述我对在哪里包含它感到困惑。我尝试添加docker-compose-base.yaml文件中不存在的字段,但它在运行命令时给了我错误docker exec -it cli bash,说没有 cli 容器。所以我决定使用原始文件,完全忽略了这一步。

标签: hyperledger-fabrichyperledgerhyperledger-composer

解决方案


(终于知道怎么用了)感谢朋友,终于找到了解决办法。

“对等链代码调用”没有标志“peerAddresses”。Hyperledger Fabric 教程文档中给出的代码可能已过时或不正确。

这可以在参考文档中看到:https ://hyperledger-fabric.readthedocs.io/en/release-1.1/commands/peerchaincode.html

因此,删除 peerAddresses 并编写类似的内容可能会解决该错误。

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"]}'

推荐阅读