-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
57 lines (43 loc) · 1.32 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"os"
"path/filepath"
"github.com/kaspanet/kaspad/domain/dagconfig"
"github.com/kaspanet/kaspad/infrastructure/logger"
"github.com/kaspanet/kaspad/util"
"github.com/jessevdk/go-flags"
)
const (
defaultLogFilename = "kaspa-tx-sender.log"
defaultErrLogFilename = "kaspa-tx-sender-err.log"
)
var (
defaultHomeDir = util.AppDir("kaspa-tx-sender", false)
// Default configuration options
defaultLogFile = filepath.Join(defaultHomeDir, defaultLogFilename)
defaultErrLogFile = filepath.Join(defaultHomeDir, defaultErrLogFilename)
)
type configFlags struct {
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
RPCServer string `long:"rpcserver" short:"s" description:"RPC server to connect to"`
ActiveNetParams *dagconfig.Params
}
var cfg *configFlags
func activeConfig() *configFlags {
return cfg
}
func parseConfig() error {
cfg = &configFlags{}
parser := flags.NewParser(cfg, flags.PrintErrors|flags.HelpFlag)
_, err := parser.Parse()
if err != nil {
if err, ok := err.(*flags.Error); ok && err.Type == flags.ErrHelp {
os.Exit(0)
}
return err
}
cfg.ActiveNetParams = &dagconfig.DevnetParams
log.SetLevel(logger.LevelInfo)
initLogs(backendLog, defaultLogFile, defaultErrLogFile)
return nil
}