mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-28 17:56:50 +00:00

* [NOD-140] Converted DNSSeeder to use btclog. * [NOD-140] Converted MiningSimulator to use btclog. * [NOD-140] Converted TxGen to use btclog. * [NOD-140] Fixed log level in handlePanic in txgen. * [NOD-140] Renamed logger to log everywhere. Removed superfluous flag-setting to go-log.
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/daglabs/btcd/util"
|
|
"path/filepath"
|
|
|
|
"github.com/jessevdk/go-flags"
|
|
)
|
|
|
|
const (
|
|
defaultLogFilename = "miningsimulator.log"
|
|
)
|
|
|
|
var (
|
|
// Default configuration options
|
|
defaultHomeDir = util.AppDataDir("miningsimulator", false)
|
|
defaultLogFile = filepath.Join(defaultHomeDir, defaultLogFilename)
|
|
)
|
|
|
|
type config struct {
|
|
AddressListPath string `long:"addresslist" description:"Path to a list of nodes' JSON-RPC endpoints" required:"true"`
|
|
CertificatePath string `long:"cert" description:"Path to certificate accepted by JSON-RPC endpoint"`
|
|
DisableTLS bool `long:"notls" description:"Disable TLS"`
|
|
Verbose bool `long:"verbose" short:"v" description:"Enable logging of RPC requests"`
|
|
}
|
|
|
|
func parseConfig() (*config, error) {
|
|
cfg := &config{}
|
|
parser := flags.NewParser(cfg, flags.PrintErrors|flags.HelpFlag)
|
|
_, err := parser.Parse()
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if cfg.CertificatePath == "" && !cfg.DisableTLS {
|
|
return nil, errors.New("--notls has to be disabled if --cert is used")
|
|
}
|
|
|
|
if cfg.CertificatePath != "" && cfg.DisableTLS {
|
|
return nil, errors.New("--cert should be omitted if --notls is used")
|
|
}
|
|
|
|
initLogRotator(defaultLogFile)
|
|
|
|
return cfg, nil
|
|
}
|