Skip to content

Commit 8dfe812

Browse files
committed
Address PR comments
Signed-off-by: Liran Funaro <liran.funaro@gmail.com>
1 parent 3759426 commit 8dfe812

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

cmd/config/samples/loadgen.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ load-profile:
5252
channel-id: mychannel
5353
namespace-policies:
5454
0:
55+
# Supported schemes: MSP, ECDSA, EDDSA, and BLS
56+
# If MSP is used, the default policy is requiring
57+
# endorsement by all peer organizations.
5558
scheme: ECDSA
5659
seed: 10
5760
_meta:

loadgen/workload/config.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,13 @@ type PolicyProfile struct {
109109
// If ConfigBlockPath is specified, this value is ignored.
110110
OrdererEndpoints []*commontypes.OrdererEndpoint `mapstructure:"orderer-endpoints" yaml:"orderer-endpoints"`
111111

112-
// ConfigBlockPath may specify the config block to use.
113-
// If this field is empty, a default config block will be generated.
114-
ConfigBlockPath string `mapstructure:"config-block-path" yaml:"config-block-path"`
115-
116112
// CryptoMaterialPath may specify the path to the material generated by CreateDefaultConfigBlockWithCrypto().
117113
// If this field is empty, the material will be generated into a temporary folder.
118114
// If this path does not exist, or it is empty, the material will be generated into it.
119-
// If ConfigBlockPath is empty, the config block will be fetched from this folder.
115+
// If ConfigBlockPath is empty, the config block will be fetched from CryptoMaterialPath.
116+
// Otherwise, it will be fetched from ConfigBlockPath regardless of CryptoMaterialPath.
120117
CryptoMaterialPath string `mapstructure:"crypto-material-path" yaml:"crypto-material-path"`
118+
ConfigBlockPath string `mapstructure:"config-block-path" yaml:"config-block-path"`
121119

122120
// ChannelID and Identity are used to create the TX envelop.
123121
ChannelID string `mapstructure:"channel-id"`

loadgen/workload/config_tx.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ func CreateConfigBlock(policy *PolicyProfile) (*common.Block, error) {
8686
// prepareCryptoMaterial generates the crypto material for a policy if it wasn't generated before.
8787
func prepareCryptoMaterial(policy *PolicyProfile) error {
8888
if policy.CryptoMaterialPath == "" {
89-
tempDir, err := os.MkdirTemp("", "sc-loadgen-crypto-*")
89+
tempDir, err := makeTemporaryDir()
9090
if err != nil {
91-
return errors.Wrap(err, "error creating temp dir for crypto-material")
91+
return err
9292
}
9393
policy.CryptoMaterialPath = tempDir
9494
}
@@ -114,16 +114,24 @@ func prepareCryptoMaterial(policy *PolicyProfile) error {
114114

115115
// CreateDefaultConfigBlock creates a config block with default values.
116116
func CreateDefaultConfigBlock(conf *ConfigBlock, profileName string) (*common.Block, error) {
117-
target, err := os.MkdirTemp("", "sc-loadgen-crypto-*")
117+
target, err := makeTemporaryDir()
118118
if err != nil {
119-
return nil, errors.Wrap(err, "failed creating temp dir for config block generation")
119+
return nil, err
120120
}
121121
defer func() {
122122
_ = os.RemoveAll(target)
123123
}()
124124
return CreateDefaultConfigBlockWithCrypto(target, conf, profileName)
125125
}
126126

127+
func makeTemporaryDir() (string, error) {
128+
tempDir, err := os.MkdirTemp("", "sc-loadgen-crypto-*")
129+
if err != nil {
130+
return "", errors.Wrap(err, "error creating temp dir for crypto-material")
131+
}
132+
return tempDir, nil
133+
}
134+
127135
// CreateDefaultConfigBlockWithCrypto creates a config block with crypto material.
128136
func CreateDefaultConfigBlockWithCrypto(
129137
targetPath string, conf *ConfigBlock, profileName string,

0 commit comments

Comments
 (0)