报错1
本报错是fabric 1.X
Error: error getting chaincode bytes: failed to calculate dependencies: incomplete package: github.com/hyperledger/fabric-chaincode-go/shim
!!!!!!!!!!!!!!! Chaincode packaging on peer0.org1 has failed !!!!!!!!!!!!!!!!
apt-get install go 的版本比较低。卸载了先。然后下载go1.13.5.linux-amd64.tar.gz进行安装。
# tar zxvf go1.13.5.linux-amd64.tar.gz
# mv go /usr/local/
# vim /etc/profile
#set golang env
export GOROOT=/usr/local/go
export GOPATH=/opt/goworkspace
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin
# source /etc/profile
# go version
go version go1.13.5 linux/amd64
环境变量:
# go env
换成国内代理:
# go env -w GOPROXY=https://goproxy.cn
# export GOPROXY=https://goproxy.cn
运行测试网络
#cd /opt/fabric/fabric-samples/first-network
# ./byfn.sh down
#./byfn.sh up -c mychannel -s couchdb -a
有网友评论按照以上操作换了go版本后,依然报错!?
首先检查下fabric的版本,网友们的是2.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 ===========
找不到github.com/hyperledger/fabric-contract-api-go/contractapi依赖包,说明下载golang github.com/hyperledger/fabric-contract-api-go/contractapi依赖包的时候失败了。
那么我们需要解决Golang1.13.x 无法下载问题,那这样问题其实和之前一样,主要是找个国内靠谱的代理,然后再重复的试试。
注意:Fabric 2.0的链码与1.x相比,主要区别为
1、导入包的不同
1.x导入的包为:
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
2.0导入的包为:
"github.com/hyperledger/fabric-contract-api-go/contractapi"
2、方法结构不同
Fabric 2.0链码没有 Invoke(stub shim.ChaincodeStubInterface) pb.Response{ }方法。
3、方法中调用形式参数类型、返回值不同
1.x方法为:
createCar1(APIstub shim.ChaincodeStubInterface, args []string) pb.Response { }
2.0方法为:
Create(ctx contractapi.TransactionContextInterface,key string,value string)error { }
报错2
Creating channel...
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=1
+ set +x
2020-03-31 09:44:51.055 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
Error: got unexpected status: BAD_REQUEST -- error applying config update to existing channel 'mychannel': error authorizing update: error validating ReadSet: proposed update requires that key [Group] /Channel/Application be at version 0, but it is currently at version 1
!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========
ERROR !!!! Test failed
root@ubuntu:/opt/fabric/fabric-samples/first-network#
已经存在mychannel,之前启动的fabric network没有正常停止,如果之前执行./byfn.sh up,那么相应的执行./byfn.sh down来停止fabric network。不要直接使用docker stop 或者 docker rm 停止删除容器。
注意,环境变量的配置添加到/etc/bash.bashrc,使不论什么用户登录都生效。
|
请发表评论