【问题标题】:Hyperledger Fabric channel block is not getting created using golang but successfully created using manual cliHyperledger Fabric 通道块不是使用 golang 创建的,而是使用手动 cli 成功创建的
【发布时间】:2018-11-21 17:11:33
【问题描述】:

我在 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 路径,但我仍然不知道这有什么问题。

非常感谢任何建议/评论。

【问题讨论】:

  • 如果我理解正确,您是在尝试生成创世块吗?
  • 我正在尝试生成通道配置块。 mychannel.block

标签: hyperledger-fabric hyperledger


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-07-26
    • 2021-09-25
    • 2019-05-21
    • 2018-06-19
    • 2019-06-11
    • 1970-01-01
    • 2018-12-17
    • 2019-01-06
    • 1970-01-01
    相关资源
    最近更新 更多