本文介绍了实例化链码时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助我解决这个问题,当我实例化我的链码时发生错误:
Please help me this issue, error happened when I instantiate my chaincode:
当前,我猜是与shim软件包有关的问题,因为我已将其删除到utils软件包中,成功实例化了.
Currently, I guess the issue related to shim package, because I remove it in my utils package, instantiate successfully.
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
}
问题:
织物版本1.1.0
转到1.9.2版
推荐答案
将结构升级到1.2.0后,我遇到了同样的问题. Fabric 1.2.0需要go1.10.x.所以我将go lang升级到1.10.3,它像一个魅力一样工作.
I faced the same problem after upgrading fabric to 1.2.0. Fabric 1.2.0 requires go 1.10.x. So I upgraded go lang to 1.10.3 and it worked like a charm.
这篇关于实例化链码时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!