7 log "github.com/sirupsen/logrus"
9 "github.com/vapor/crypto/ed25519/chainkd"
12 func NewConfig() *Config {
13 if len(os.Args) <= 1 {
14 log.Fatal("Please setup the config file path")
17 return NewConfigWithPath(os.Args[1])
20 func NewConfigWithPath(path string) *Config {
21 configFile, err := os.Open(path)
23 log.WithFields(log.Fields{"err": err, "file_path": os.Args[1]}).Fatal("fail to open config file")
25 defer configFile.Close()
28 if err := json.NewDecoder(configFile).Decode(cfg); err != nil {
29 log.WithField("err", err).Fatal("fail to decode config file")
36 GinGonic GinGonic `json:"gin-gonic"`
37 MySQLConfig MySQLConfig `json:"mysql"`
38 Warders []Warder `json:"warders"`
39 Mainchain Chain `json:"mainchain"`
40 Sidechain Chain `json:"sidechain"`
43 type GinGonic struct {
44 ListeningPort uint64 `json:"listening_port"`
45 IsReleaseMode bool `json:"is_release_mode"`
48 type MySQLConfig struct {
49 Connection MySQLConnection `json:"connection"`
50 LogMode bool `json:"log_mode"`
53 type MySQLConnection struct {
54 Host string `json:"host"`
55 Port uint `json:"port"`
56 Username string `json:"username"`
57 Password string `json:"password"`
58 DbName string `json:"database"`
62 Position uint8 `json:"position"`
63 XPub chainkd.XPub `json:"xpub"`
64 HostPort string `json:"host_port"`
65 IsLocal bool `json:"is_local"`
69 Name string `json:"name"`
70 Upstream string `json:"upstream"`
71 SyncSeconds uint64 `json:"sync_seconds"`
72 Confirmations uint64 `json:"confirmations"`