Reputation: 6786
I have a program in Go which automatically generates a channel configuration block. If I do it manually using a terminal it generates a block successfully as shown below:
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/[email protected]/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
and I can see the mychannel.block
in the directory.
But When I do the same thing using a Go Program. It throws an error as shown below:
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
The source code of the program is shown below:
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()
I have set path of FABRIC_CFG_PATH same as I did in terminal but still I have no idea what is wrong in this.
Any suggestion/comment would be really appreciated.
Upvotes: 1
Views: 371
Reputation: 6786
The CORE_PEER_MSPCONFIGPATH
was not correct. Setting up a correct path fixed my issue
Upvotes: 1