Hyperledger Fabric通道块不是使用golang创建的,而是使用手动cli成功创建的

时间:2018-11-19 11:01:11

标签: hyperledger-fabric hyperledger

我在Go中有一个程序,该程序会自动生成一个通道配置块。如果我使用终端手动进行操作,则会成功生成一个块,如下所示:

export CORE_PEER_ADDRESS=peer0.debutinfotech.com:7051
export CORE_PEER_LOCALMSPID=debutinfotechMSP
export CORE_PEER_MSPCONFIGPATH=/home/akshay/go/src/ConfigTool/Go/network/crypto-config/peerOrganizations/debutinfotech.com/users/Admin@debutinfotech.com/msp
export FABRIC_CFG_PATH=/home/akshay/.fabdep/config
peer channel create -o orderer0.example.com:7050 -f network/channel-artifacts/mychannel.tx -c mychannel
2018-11-19 16:28:16.162 IST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2018-11-19 16:28:16.205 IST [cli/common] readBlock -> INFO 002 Got status: &{NOT_FOUND}
2018-11-19 16:28:16.205 IST [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-11-19 16:28:16.413 IST [cli/common] readBlock -> INFO 004 Received block: 0

我可以在目录中看到mychannel.block

但是当我使用Go程序执行相同的操作时。它将引发错误,如下所示:

2018-11-19 16:22:42.639 IST [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2018-11-19 16:22:42.644 IST [common/tools/configtxgen/localconfig] Load -> CRIT 002 Error reading configuration:  Unsupported Config Type ""
panic: Error reading configuration: Unsupported Config Type ""

goroutine 1 [running]:
github.com/hyperledger/fabric/vendor/github.com/op/go-logging.(*Logger).Panic(0xc42015b6e0, 0xc420586220,0x2, 0x2)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/vendor/github.com/op/go-logging/logger.go:188 +0xbd
github.com/hyperledger/fabric/common/tools/configtxgen/localconfig.Load(0x1494bb9, 0x16, 0x0, 0x0, 0x0, 0xbef4c35ea622c17d)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/common/tools/configtxgen/localconfig/config.go:277 +0x469
github.com/hyperledger/fabric/peer/channel.createChannelFromDefaults(0xc4204088c0, 0x0, 0x0, 0x0)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:72 +0x65
github.com/hyperledger/fabric/peer/channel.sendCreateChainTransaction(0xc4204088c0, 0x0, 0x0)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:153 +0x21a
github.com/hyperledger/fabric/peer/channel.executeCreate(0xc4204088c0, 0xc4204088c0, 0x0)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:175 +0x2f
github.com/hyperledger/fabric/peer/channel.create(0xc4204aeb40, 0xc4203ff2c0, 0x0, 0x6, 0x0, 0x0, 0x0)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:243 +0x4c
github.com/hyperledger/fabric/peer/channel.createCmd.func1(0xc4204aeb40, 0xc4203ff2c0, 0x0, 0x6, 0x0, 0x0)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/peer/channel/create.go:57 +0x52
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).execute(0xc4204aeb40, 0xc4203ff200, 0x6, 0x6, 0xc4204aeb40, 0xc4203ff200)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:698 +0x46d
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x1c9e320, 0x1d86c30, 0xf, 0x4)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:783 +0x2e4
github.com/hyperledger/fabric/vendor/github.com/spf13/cobra.(*Command).Execute(0x1c9e320, 0x4, 0xffffffffffffffff)
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/vendor/github.com/spf13/cobra/command.go:736 +0x2b
main.main()
        /w/workspace/fabric-nightly-release-job-release-1.2-x86_64/gopath/src/github.com/hyperledger/fabric/peer/main.go:97 +0x5bf

该程序的源代码如下所示:

dir := utils.GetRootDir()

        os.Setenv("CORE_PEER_MSPCONFIGPATH", *peerOrg.UserDir+"/Admin@"+peerOrg.OrgDomain+"/msp")
        os.Setenv("CORE_PEER_LOCALMSPID", peerOrg.MSPID)
        os.Setenv("CORE_PEER_ADDRESS", "peer0."+peerOrg.OrgDomain+":7051")
        os.Setenv("FABRIC_CFG_PATH", os.ExpandEnv("$HOME")+"/.fabdep/config")
        command := exec.Command("peer", "channel", "create", "-o", "orderer0."+ordererOrg.OrgDomain+":7050", "-c", channel.Name, "--outputBlock", dir+"/network/"+channel.Name+".block")
        command.Env = os.Environ()

        result, err := command.CombinedOutput()

我已经在终端中设置了FABRIC_CFG_PATH的路径,但是我仍然不知道这有什么问题。

任何建议/评论将不胜感激。

1 个答案:

答案 0 :(得分:1)

CORE_PEER_MSPCONFIGPATH不正确。设置正确的路径可以解决我的问题