Hyperledger Fabric 1.2 Java SDK-使用输入流实例化链码时出现“找不到包”

时间:2020-06-15 17:07:17

标签: hyperledger-fabric blockchain hyperledger-chaincode chaincode

我正在尝试安装并实例化从输入流创建的链码包:

      final InstallProposalRequest installProposalRequest = hfClient.newInstallProposalRequest();
      final String name = "mychaincode";
      installProposalRequest.setChaincodeID(ChaincodeID.newBuilder()
          .setName(name)
          .setVersion("1")
          .setPath(name)
          .build()
      );

      final File sourceDirectory = new File("/home/ec2-user/go/src/github.com/mychaincode/main");
      final byte[] packageBytes = Utils.generateTarGz(sourceDirectory, null, null);
      installProposalRequest.setChaincodeInputStream(new ByteArrayInputStream(packageBytes));

      final Collection<ProposalResponse> proposalResponses = hfClient
          .sendInstallProposal(installProposalRequest, channel.getPeers());

该安装似乎运行良好。我可以通过尝试再次安装并得到此错误来验证这一点:

nd-3N2H52Y4RZBONK3LPBJIIB3NZE=FAILURE: error installing chaincode code mychaincode:1(chaincode /var/hyperledger/production/chaincodes/mychaincode.1 exists

但是尝试实例化时,出现以下错误:

error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "can't load package: package mychaincode: cannot find package "mychaincode" in any of:
        /opt/go/src/mychaincode (from $GOROOT)
        /chaincode/input/src/mychaincode (from $GOPATH)
        /opt/gopath/src/mychaincode
"

似乎InstallProposalRequest.setPath(...)控制着程序包的搜索位置,但是我不确定path的值应该是什么。 我不太了解为什么要提供包含源的InputStream(路径是强制性的),为什么需要提供路径。

谢谢。

0 个答案:

没有答案