/
gen_config.go
133 lines (128 loc) · 3.22 KB
/
gen_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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package node
import (
"bchain.io/communication/p2p"
)
func (c Config) MarshalTOML() (interface{}, error) {
type Config struct {
Name string `toml:"-"`
UserIdent string `toml:",omitempty"`
Version string `toml:"-"`
DataDir string
P2P p2p.Config
KeyStoreDir string `toml:",omitempty"`
UseLightweightKDF bool `toml:",omitempty"`
NoUSB bool `toml:",omitempty"`
IPCPath string `toml:",omitempty"`
HTTPHost string `toml:",omitempty"`
HTTPPort int `toml:",omitempty"`
HTTPCors []string `toml:",omitempty"`
HTTPModules []string `toml:",omitempty"`
WSHost string `toml:",omitempty"`
WSPort int `toml:",omitempty"`
WSOrigins []string `toml:",omitempty"`
WSModules []string `toml:",omitempty"`
WSExposeAll bool `toml:",omitempty"`
}
var enc Config
enc.Name = c.Name
enc.UserIdent = c.UserIdent
enc.Version = c.Version
enc.DataDir = c.DataDir
enc.P2P = c.P2P
enc.KeyStoreDir = c.KeyStoreDir
enc.UseLightweightKDF = c.UseLightweightKDF
enc.NoUSB = c.NoUSB
enc.IPCPath = c.IPCPath
enc.HTTPHost = c.HTTPHost
enc.HTTPPort = c.HTTPPort
enc.HTTPCors = c.HTTPCors
enc.HTTPModules = c.HTTPModules
enc.WSHost = c.WSHost
enc.WSPort = c.WSPort
enc.WSOrigins = c.WSOrigins
enc.WSModules = c.WSModules
enc.WSExposeAll = c.WSExposeAll
return &enc, nil
}
func (c *Config) UnmarshalTOML(unmarshal func (interface{}) error) error {
type Config struct {
Name *string `toml:"-"`
UserIdent *string `toml:",omitempty"`
Version *string `toml:"-"`
DataDir *string
P2P *p2p.Config
KeyStoreDir *string `toml:",omitempty"`
UseLightweightKDF *bool `toml:",omitempty"`
NoUSB *bool `toml:",omitempty"`
IPCPath *string `toml:",omitempty"`
HTTPHost *string `toml:",omitempty"`
HTTPPort *int `toml:",omitempty"`
HTTPCors []string `toml:",omitempty"`
HTTPModules []string `toml:",omitempty"`
WSHost *string `toml:",omitempty"`
WSPort *int `toml:",omitempty"`
WSOrigins []string `toml:",omitempty"`
WSModules []string `toml:",omitempty"`
WSExposeAll *bool `toml:",omitempty"`
}
var dec Config
if err := unmarshal(&dec); err != nil {
return err
}
if dec.Name != nil {
c.Name = *dec.Name
}
if dec.UserIdent != nil {
c.UserIdent = *dec.UserIdent
}
if dec.Version != nil {
c.Version = *dec.Version
}
if dec.DataDir != nil {
c.DataDir = *dec.DataDir
}
if dec.P2P != nil {
c.P2P = *dec.P2P
}
if dec.KeyStoreDir != nil {
c.KeyStoreDir = *dec.KeyStoreDir
}
if dec.UseLightweightKDF != nil {
c.UseLightweightKDF = *dec.UseLightweightKDF
}
if dec.NoUSB != nil {
c.NoUSB = *dec.NoUSB
}
if dec.IPCPath != nil {
c.IPCPath = *dec.IPCPath
}
if dec.HTTPHost != nil {
c.HTTPHost = *dec.HTTPHost
}
if dec.HTTPPort != nil {
c.HTTPPort = *dec.HTTPPort
}
if dec.HTTPCors != nil {
c.HTTPCors = dec.HTTPCors
}
if dec.HTTPModules != nil {
c.HTTPModules = dec.HTTPModules
}
if dec.WSHost != nil {
c.WSHost = *dec.WSHost
}
if dec.WSPort != nil {
c.WSPort = *dec.WSPort
}
if dec.WSOrigins != nil {
c.WSOrigins = dec.WSOrigins
}
if dec.WSModules != nil {
c.WSModules = dec.WSModules
}
if dec.WSExposeAll != nil {
c.WSExposeAll = *dec.WSExposeAll
}
return nil
}