gpt4 book ai didi

hyperledger-fabric - Vendored Chaincode 具有错误的依赖关系

转载 作者:行者123 更新时间:2023-12-04 07:55:51 28 4
gpt4 key购买 nike

我有具有以下目录结构的链码

$GOPATH/myproject/chaincode/mycc/go
├── mycc.go
├── chaincode
│   └── chaincode.go
└── vendor
├── github.com
├── ...

因为我使用了 hyperledgers cid 包,所以我使用 vendoring 并且在链代码旁边有 vendor 目录。现在对于可测试性,mycc.go 只包含 main 函数:

package main

import (
"myproject/chaincode/mycc/go/chaincode"
"github.com/hyperledger/fabric/core/chaincode/shim"
)

func main() {
err := shim.Start(new(chaincode.MyChaincode))
if err != nil {
logger.Error(err.Error())
}
}

chaincode.go 实现链码的其余部分,包括带有 InitInvokeMyChaincode 结构等。相关导入与mycc.go中的相同:

"github.com/hyperledger/fabric/core/chaincode/shim"

在链代码的实例化过程中,某些依赖项似乎混淆了,因为我收到错误消息:

*chaincode.MyChaincode does not implement "chaincode/mycc/go/vendor/github.com/hyperledger/fabric/core/chaincode/shim".Chaincode (wrong type for Init method)
have Init("chaincode/mycc/go/vendor/myproject/chaincode/mycc/go/vendor/github.com/hyperledger/fabric/core/chaincode/shim".ChaincodeStubInterface) "chaincode/approvalcc/go/vendor/ma/chaincode/approvalcc/go/vendor/github.com/hyperledger/fabric/protos/peer".Response
want Init("chaincode/mycc/go/vendor/github.com/hyperledger/fabric/core/chaincode/shim".ChaincodeStubInterface) "chaincode/mycc/go/vendor/github.com/hyperledger/fabric/protos/peer".Response

很明显,内部链代码包中的导入似乎被错误解析,供应商目录在路径中出现了两次。

最佳答案

构建链代码的 fabric-ccenv 容器试图“提供帮助”,但在容器内的 GOPATH 中包含 shim。它还最终包括 shim/ext/... 文件夹,但不幸的是实际上并没有正确地包括它们的传递依赖项。

当您将其与链代码安装/打包命令的方式结合起来也试图提供帮助以及您对供应商的尝试时,事情变得很糟糕。

我实际上只是推送了一个针对 1.4.2 的修复程序来解决 fabric-ccenv 问题。

关于hyperledger-fabric - Vendored Chaincode 具有错误的依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56909688/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com