7 log "github.com/sirupsen/logrus"
8 "github.com/vapor/crypto/ed25519/chainkd"
10 "github.com/vapor/toolbar/common"
13 func NewConfig() *Config {
14 if len(os.Args) <= 1 {
15 log.Fatal("Please setup the config file path")
18 return NewConfigWithPath(os.Args[1])
21 func NewConfigWithPath(path string) *Config {
22 configFile, err := os.Open(path)
24 log.WithFields(log.Fields{"err": err, "file_path": os.Args[1]}).Fatal("fail to open config file")
26 defer configFile.Close()
29 if err := json.NewDecoder(configFile).Decode(cfg); err != nil {
30 log.WithField("err", err).Fatal("fail to decode config file")
37 NetworkID uint64 `json:"network_id"`
38 MySQLConfig common.MySQLConfig `json:"mysql"`
39 CheckFreqSeconds uint64 `json:"check_frequency_seconds"`
40 Policy Policy `json:"policy"`
41 Nodes []Node `json:"seeds"`
46 Confirmations uint64 `json:"confirmations"`
47 RequiredLantencyMS uint64 `json:"required_lantency_ms"`
51 Alias string `json:"alias"`
52 XPub *chainkd.XPub `json:"xpub"`
53 PublicKey string `json:"public_key"`
54 Host string `json:"host"`
55 Port uint16 `json:"port"`
59 ListeningPort bool `json:"listening_port"`
60 AccessToken string `json:"access_token"`
61 IsReleaseMode bool `json:"is_release_mode"`