-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathconfig.go
67 lines (62 loc) · 1.6 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
58
59
60
61
62
63
64
65
66
67
package main
import (
"encoding/json"
"os"
)
type config struct {
Log struct {
Level string `json:"level"`
File string `json:"file"`
} `json:"log"`
StratumServer struct {
Address string `json:"address"`
Port int `json:"port"`
BackupInterval string `json:"backup_interval"`
OmitAgentStatus []string `json:"omit_agent_status"`
} `json:"stratum_server"`
APIServer struct {
Address string `json:"address"`
Port int `json:"port"`
AuthUser string `json:"auth_user"`
AuthPass string `json:"auth_pass"`
} `json:"api_server"`
Storage struct {
Address string `json:"address"`
Port int `json:"port"`
Db int `json:"db"`
Password string `json:"password"`
} `json:"storage"`
Node struct {
Address string `json:"address"`
APIPort int `json:"api_port"`
StratumPort int `json:"stratum_port"`
AuthUser string `json:"auth_user"`
AuthPass string `json:"auth_pass"`
Diff int `json:"diff"`
BlockTime int `json:"block_time"`
} `json:"node"`
Wallet struct {
Address string `json:"address"`
OwnerAPIVersion string `json:"owner_api_version"`
OwnerAPIPort int `json:"owner_api_port"`
AuthUser string `json:"auth_user"`
AuthPass string `json:"auth_pass"`
} `json:"wallet"`
Payer struct {
Time string `json:"time"`
Fee float64 `json:"fee"`
} `json:"payer"`
}
func parseConfig() *config {
f, err := os.Open("config.json")
if err != nil {
panic(err)
}
var conf config
dec := json.NewDecoder(f)
err = dec.Decode(&conf)
if err != nil {
panic(err)
}
return &conf
}