@@ -39,7 +39,7 @@ import (
3939
4040// CmdGenerate is cql generate command entity.
4141var CmdGenerate = & Command {
42- UsageLine : "cql generate [common params] [-source template_file] [-private existing_private_key] [dest_path]" ,
42+ UsageLine : "cql generate [common params] [-source template_file] [-miner] [- private existing_private_key] [dest_path]" ,
4343 Short : "generate a folder contains config file and private key" ,
4444 Long : `
4545Generate generates private.key and config.yaml for CovenantSQL.
@@ -56,12 +56,14 @@ or input a passphrase by
5656var (
5757 privateKeyParam string
5858 source string
59+ minerListenAddr string
5960)
6061
6162func init () {
6263 CmdGenerate .Run = runGenerate
6364 CmdGenerate .Flag .StringVar (& privateKeyParam , "private" , "" , "custom private for config generation" )
6465 CmdGenerate .Flag .StringVar (& source , "source" , "" , "source config file template for config generation" )
66+ CmdGenerate .Flag .StringVar (& minerListenAddr , "miner" , "" , "generate miner config with specified listen address" )
6567
6668 addCommonFlags (CmdGenerate )
6769}
@@ -218,6 +220,9 @@ func runGenerate(cmd *Command, args []string) {
218220 if source == "" {
219221 // Load testnet config
220222 rawConfig = testnet .GetTestNetConfig ()
223+ if minerListenAddr != "" {
224+ testnet .SetMinerConfig (rawConfig )
225+ }
221226 } else {
222227 // Load from template file
223228 sourceConfig , err := ioutil .ReadFile (source )
@@ -241,13 +246,18 @@ func runGenerate(cmd *Command, args []string) {
241246 if rawConfig .KnownNodes == nil {
242247 rawConfig .KnownNodes = make ([]proto.Node , 0 , 1 )
243248 }
244- rawConfig . KnownNodes = append ( rawConfig . KnownNodes , proto.Node {
249+ node := proto.Node {
245250 ID : cliNodeID ,
246251 Role : proto .Client ,
247252 Addr : "0.0.0.0:15151" ,
248253 PublicKey : publicKey ,
249254 Nonce : nonce .Nonce ,
250- })
255+ }
256+ if minerListenAddr != "" {
257+ node .Role = proto .Miner
258+ node .Addr = minerListenAddr
259+ }
260+ rawConfig .KnownNodes = append (rawConfig .KnownNodes , node )
251261
252262 // Write config
253263 out , err := yaml .Marshal (rawConfig )
0 commit comments