1. fabric2.0.0链码打包失败
Error: error getting chaincode bytes: failed to calculate dependencies: incomplete package: github.com/hyperledger/fabric-contract-api-go/contractapi
!!!!!!!!!!!!!!! Chaincode packaging on peer0.org1 has failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========
原因是golang版本太新,我装的是1.13.14,换成1.13.4问题解决。
2. fabric2.x链码打包时go mod下载依赖超时
如果不指定代理,go mod默认从这个网址下载依赖,速度很慢,甚至下载失败
https://proxy.golang.org
通过环境变量指定阿里云的代理,下载速度会很快
export GOPROXY=https://mirrors.aliyun.com/goproxy/
git clone下载速度慢,可以通过一下方法设置git代理
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
3. 下载链码依赖时,哈希校验不通过
暂时关掉哈希校验
go env -w GOSUMDB=off
下载完依赖后,再设置回去
go env -w GOSUMDB="sum.golang.org"
或者
rm go.mod
go clean -modcache
go mod tidy
或者用下载package的哈希替换go.sum里面的值
4. windows下使用MockStub测试链码报错
错误如下:
cannot use uintptr(unsafe.Pointer(&sd[0])) (type uintptr) as type *"golang.org/x/sys/windows".SECURITY_DESCRIPTOR in assignment
原因是链码依赖的软件版本有问题,在go.mod替换golang.org/x/sys的软件版本
module example.org/chaincode
go 1.13
require (
github.com/Knetic/govaluate v3.0.0+incompatible // indirect
github.com/Shopify/sarama v1.27.1 // indirect
github.com/fsouza/go-dockerclient v1.6.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect
github.com/hashicorp/go-version v1.2.1 // indirect
github.com/hyperledger/fabric v1.4.6
github.com/hyperledger/fabric-amcl v0.0.0-20190902191507-f66264322317 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/onsi/gomega v1.10.3 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/spf13/viper v1.5.0 // indirect
github.com/sykesm/zap-logfmt v0.0.3 // indirect
go.uber.org/zap v1.13.0 // indirect
google.golang.org/grpc v1.25.1 // indirect
)
replace golang.org/x/sys => golang.org/x/sys v0.0.0-20190830141801-acfa387b8d69