gpt4 book ai didi

go - 实例化链码时出错

转载 作者:数据小太阳 更新时间:2023-10-29 03:40:54 25 4
gpt4 key购买 nike

请帮我解决这个问题,当我实例化我的链代码时发生错误:

目前,我猜测问题与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
}

问题:

Error: Error endorsing chaincode: rpc error: code = Unknown desc = error starting container: Failed to generate platform-specific docker build: Error returned from build: 2 "# ~vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive ~vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:364:5: hdr.Format undefined (type *tar.Header has no field or method Format) ~vendor/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 (type *tar.Header has no field or method Format) ~/vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:1166:17: undefined: tar.FormatPAX

结构版本 1.1.0

转到版本 1.9.2

最佳答案

将 fabric 升级到 1.2.0 后,我遇到了同样的问题。 Fabric 1.2.0 需要 go 1.10.x。所以我将 go lang 升级到 1.10.3,它的效果非常好。

关于go - 实例化链码时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50939512/

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