6 Star 47 Fork 28

Hyperledger/fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
configtxgen.go 2.30 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package runner
import (
"fmt"
"os/exec"
"path/filepath"
. "github.com/onsi/gomega"
"github.com/tedsuo/ifrit/ginkgomon"
)
// Configtxgen creates runners that call cryptogen functions.
type Configtxgen struct {
// The location of the configtxgen executable
Path string
// The channel ID
ChannelID string
// The profile used for the channel
Profile string
// The organization for this config channel
AsOrg string
// The fabric config directory
ConfigDir string
// The fabric config directory set in the env variable
EnvConfigDir string
// The directory to write the block file
Output string
}
func (c *Configtxgen) setupCommandEnv(cmd *exec.Cmd) {
if c.EnvConfigDir != "" {
configDir, err := filepath.Abs(c.EnvConfigDir)
Expect(err).NotTo(HaveOccurred())
cmd.Env = append(cmd.Env, fmt.Sprintf("FABRIC_CFG_PATH=%s", configDir))
}
}
// OutputBlock uses configtxgen to generate genesis block for fabric.
func (c *Configtxgen) OutputBlock(extraArgs ...string) *ginkgomon.Runner {
cmd := exec.Command(
c.Path,
append([]string{
"-outputBlock", c.Output,
"-profile", c.Profile,
"-channelID", c.ChannelID,
"-configPath", c.ConfigDir,
}, extraArgs...)...,
)
c.setupCommandEnv(cmd)
return ginkgomon.New(ginkgomon.Config{
Name: "config output block",
AnsiColorCode: "32m",
Command: cmd,
})
}
func (c *Configtxgen) OutputCreateChannelTx(extraArgs ...string) *ginkgomon.Runner {
cmd := exec.Command(
c.Path,
append([]string{
"-channelID", c.ChannelID,
"-outputCreateChannelTx", c.Output,
"-profile", c.Profile,
"-configPath", c.ConfigDir,
}, extraArgs...)...,
)
c.setupCommandEnv(cmd)
return ginkgomon.New(ginkgomon.Config{
Name: "config create channel",
AnsiColorCode: "33m",
Command: cmd,
})
}
func (c *Configtxgen) OutputAnchorPeersUpdate(extraArgs ...string) *ginkgomon.Runner {
cmd := exec.Command(
c.Path,
append([]string{
"-channelID", c.ChannelID,
"-outputAnchorPeersUpdate", c.Output,
"-profile", c.Profile,
"-asOrg", c.AsOrg,
"-configPath", c.ConfigDir,
}, extraArgs...)...,
)
c.setupCommandEnv(cmd)
return ginkgomon.New(ginkgomon.Config{
Name: "config update peer",
AnsiColorCode: "34m",
Command: cmd,
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hyperledger/fabric.git
git@gitee.com:hyperledger/fabric.git
hyperledger
fabric
fabric
v1.2.1

搜索帮助