背书者实例化具有错误“找不到包"的链码. [英] Endorsers Instantiate Chaincode with error "cannot find package"

查看:206
本文介绍了背书者实例化具有错误“找不到包"的链码.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个链码,并向其中导入了一个包.

I created a chaincode and I imported a package to it.

import (
"bytes"
"encoding/json"
"fmt"
"strings"
"golang.org/x/crypto/bcrypt"
"github.com/hyperledger/fabric/core/chaincode/shim"
    pb "github.com/hyperledger/fabric/protos/peer")

我可以将该链码安装到所有背书人.但是当我将其实例化给所有背书人时,它遇到了错误:

I can install that chaincode to all endorsers. But when I instantiated it to all endorsers, it faced the error:

endorser failed with error starting container: error starting container: Failed to generate platform-specific docker build: Error returned from build: 1 "/chaincode/input/src/github.com/marbles02/marbles_chaincode.go:85:2: cannot find package "golang.org/x/crypto/bcrypt" in any of:
/usr/local/go/src/golang.org/x/crypto/bcrypt (from $GOROOT)
/chaincode/input/src/golang.org/x/crypto/bcrypt (from $GOPATH)
/go/src/golang.org/x/crypto/bcrypt

我试图将golang.org/x/crypto/bcrypt程序包复制到根目录中的/usr/local/go/src/,但是它具有相同的错误.

I tried to copy golang.org/x/crypto/bcrypt package to the /usr/local/go/src/ in the root directory, but it has the same error.

推荐答案

尝试使用以下命令在chaincode目录中安装依赖项:

Try Installing the dependencies in the chaincode directory using below commands:

  1. go mod init将创建go.modgo.sum文件.
  2. go mod vendor用于创建vendor目录.
  1. go mod init will create go.mod and go.sum files.
  2. go mod vendor for creating a vendor directory.

此外,如果使用fabric:v2.X.X,则shimpeer程序包将移至其他库. 因此,将chainc.go文件中的peershim软件包更改为下面的内容.

Also if using fabric:v2.X.X then shim and peer packages moved to different libraries. so change the peer and shim packages to below in the chaincode.go file.

  1. peer-> github.com/hyperledger/fabric-protos-go/peer.
  2. shim-> github.com/hyperledger/fabric-chaincode-go/shim
  1. peer --> github.com/hyperledger/fabric-protos-go/peer.
  2. shim --> github.com/hyperledger/fabric-chaincode-go/shim

在运行go mod init命令之前,请确保添加peershim更改,或者如果您已经具有vendor目录,请尝试依次按go mod tidygo mod vendor命令来更新软件包.

Make sure to add peerand shim changes before running go mod initcommand OR if you are already have a vendor directory then try go mod tidy and then go mod vendor commands to update the packages.

这篇关于背书者实例化具有错误“找不到包"的链码.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆