IBM/blockchain-application-using-fabric-java-sdk 启动遇到的

首先附上github地址:blockchain-application-using-fabric-java-sdk

我安装readme中的步骤来,把区块链网络跑起来之后,创建channel成功了,安装链码也成功了,只是最后在实例化(instantiate)链码的时候一直失败,提示:

could not build chaincode: docker build failed: docker image build failed: docker build failed: Error returned from build: 1 "/chaincode/input/src/github.com/chaincode/farcar.go:37:2: cannot find package “github.com/hyperledger/core/chaincode/shim” in any of:
/usr/local/go/src/github.com/hyperledger/core/chaincode/shim (from $GOROOT)
/chaincode/input/src/github.com/hyperledger/fabric-chaincode-go/shim (from $GOPATH)
/go/src/github.com/hyperledger/fabric-chaincode-go/shim


/chaincode/input/src/github.com/chaincode/pcurd.go:38:6: cannot find package “github.com/hyperledger/fabric/protos/peer” in any of:
/usr/local/go/src/github.com/hyperledger/fabric/protos/peer (from $GOROOT)
/chaincode/input/src/github.com/hyperledger/fabric/protos/peer (from $GOPATH)
/go/src/github.com/hyperledger/fabric/protos/peer"

这里通过2步解决这个问题。

第一步

cd到network_resources/chaincode/src/github.com/fabcar目录下,更改fabcar.go文件import的package,修改后的内容如下:

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"strconv"

    "github.com/hyperledger/fabric-chaincode-go/shim"
     sc "github.com/hyperledger/fabric-protos-go/peer"

)

第二步

 安装go1.13.15,然后执行:

go env -w GO111MODULE=on

把项目clone下来之后,cd到network_resources/chaincode/src/github.com/fabcar目录下,然后执行

go mod init
go mod vendor

然后删掉docker容器,重新跑一遍就好了

上一篇:Docker源码分析(八):Docker Container网络(下)


下一篇:论文