Chaincode installation on peer0.org1 has failed
v1.4 版本执行 ./byfn.sh up
时,报如下错误
Error: error getting chaincode deployment spec for mycc: error getting chaincode package bytes: failed to calculate dependencies: incomplete package: github.com/hyperledger/fabric/core/chaincode/shim
!!!!!!!!!!!!!!! Chaincode installation on peer0.org1 has failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========
跟脚本代码是从(github)以下逻辑报出的
installChaincode() {
PEER=$1
ORG=$2
setGlobals $PEER $ORG
VERSION=${3:-1.0}
set -x
peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt // 此处
res=$?
set +x
cat log.txt
verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has failed"
echo "===================== Chaincode is installed on peer${PEER}.org${ORG} ===================== "
echo
}
跟下逻辑,意思是说,以下依赖未找到(github)
import (
"fmt"
"strconv"
"github.com/hyperledger/fabric/core/chaincode/shim" // 未找到
pb "github.com/hyperledger/fabric/protos/peer"
)
经过对比仓库分支代码,发现release-1.4
是有的,最新的master
分支已经删掉了。
直接参考2.0版本修改下吧
修改chaincode_example02.go
import (
"bytes"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"os"
"github.com/hyperledger/fabric-chaincode-go/shim"
pb "github.com/hyperledger/fabric-protos-go/peer"
)
并在同级目录新建go.mod
module github.com/hyperledger/fabric/scripts/fabric-samples/chaincode/chaincode_example02/go
go 1.14
require (
github.com/hyperledger/fabric-chaincode-go v0.0.0-20200128192331-2d899240a7ed
github.com/hyperledger/fabric-protos-go v0.0.0-20200124220212-e9cfc186ba7b
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/genproto v0.0.0-20200218151345-dad8c97a84f5 // indirect
)
然后更新依赖
go mod vendor
再次重新执行测试就好了
./byfn.sh down
./byfn.sh up
或者
go mod init chaincode
go get github.com/hyperledger/fabric/common/util@v1.4
go get github.com/hyperledger/fabric/core/chaincode/shim@v1.4
go get github.com/hyperledger/fabric/protos/peer@v1.4