请帮我解决这个问题,当我实例化我的链码时发生了错误:
目前,我猜这个问题与shim包有关,因为我在我的utils包中删除它,成功实例化。
import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"strconv"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/protos/msp"
pb "github.com/hyperledger/fabric/protos/peer"
"github.com/myproj/models"
"github.com/myproj/packages/utils"
)
APIstub shim.ChaincodeStubInterface
...
username, _ = utils.GetCurrentUser(APIstub)
...
package utils
import (
"github.com/hyperledger/fabric/core/chaincode/shim"
"golang.org/x/crypto/bcrypt"
)
func GetCurrentUser(stub shim.ChaincodeStubInterface) (string, error) {
cert, err := GetCreatorCert(stub)
return cert.Subject.CommonName, err
}
错误:错误支持链代码:rpc错误:代码=未知desc =错误启动容器:无法生成特定于平台的docker build:从build返回错误:2“#〜vendor / github.com / hyperledger / fabric / vendor / github。 com / docker / docker / pkg / archive~proflier / github.com / hyperledger / fabric / vendor / github.com / docker / docker / pkg / archive / archive.go:364:5:hdr.Format undefined(type * tar .Header没有字段或方法格式)~supplier / github.com / hyperledger / fabric / vendor / github.com / docker / docker / pkg / archive / archive.go:364:15:undefined:tar.FormatPAX~ / vendor /github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:1166:7:hdr.Format undefined(类型* tar.Header没有字段或方法格式)〜/ vendor / github.com / hyperledger / fabric / vendor / github.com / docker / docker / pkg / archive / archive.go:1166:17:undefined:tar.FormatPAX
Fabric ver 1.1.0
转到1.9.2
将fabric升级到1.2.0后,我遇到了同样的问题。 Fabric 1.2.0需要去1.10.x.所以我将go lang升级到1.10.3,它就像一个魅力。
这可能是因为你在hyperledger / fabric文件夹中的某些文件中有旧版本。
如果您正在关注链码教程,则可以删除hyperledger / fabric文件夹。
问候
按照文档我有同样的问题。切换到分支'release-1.1'解决了这个问题。
克隆存储库后,继续:
hyperleger$ cd fabric
hyperledger/fabric$ git fetch
hyperledger/fabric$ git checkout release-1.1