-
Notifications
You must be signed in to change notification settings - Fork 0
/
feechain.go
209 lines (182 loc) · 4.92 KB
/
feechain.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package feechain
import (
"reflect"
"strings"
)
// FeechainConfig contains all the configs user can set for running feechain binary. Served as the bridge
// from user set flags to internal node configs. Also user can persist this structure to a toml file
// to avoid inputting all arguments.
type FeechainConfig struct {
Version string
General GeneralConfig
Network NetworkConfig
P2P P2pConfig
HTTP HttpConfig
WS WsConfig
RPCOpt RpcOptConfig
BLSKeys BlsConfig
TxPool TxPoolConfig
Pprof PprofConfig
Log LogConfig
Sync SyncConfig
Sys *SysConfig `toml:",omitempty"`
Consensus *ConsensusConfig `toml:",omitempty"`
Devnet *DevnetConfig `toml:",omitempty"`
Revert *RevertConfig `toml:",omitempty"`
Legacy *LegacyConfig `toml:",omitempty"`
Prometheus *PrometheusConfig `toml:",omitempty"`
DNSSync DnsSync
ShardData ShardDataConfig
}
type DnsSync struct {
Port int // replaces: Network.DNSSyncPort
Zone string // replaces: Network.DNSZone
LegacySyncing bool // replaces: Network.LegacySyncing
Client bool // replaces: Sync.LegacyClient
Server bool // replaces: Sync.LegacyServer
ServerPort int
}
type NetworkConfig struct {
NetworkType string
BootNodes []string
}
type P2pConfig struct {
Port int
IP string
KeyFile string
DHTDataStore *string `toml:",omitempty"`
DiscConcurrency int // Discovery Concurrency value
MaxConnsPerIP int
}
type GeneralConfig struct {
NodeType string
NoStaking bool
ShardID int
IsArchival bool
IsBackup bool
IsBeaconArchival bool
IsOffline bool
DataDir string
EnablePruneBeaconChain bool
}
type ShardDataConfig struct {
EnableShardData bool
DiskCount int
ShardCount int
CacheTime int
CacheSize int
}
type ConsensusConfig struct {
MinPeers int
AggregateSig bool
}
type BlsConfig struct {
KeyDir string
KeyFiles []string
MaxKeys int
PassEnabled bool
PassSrcType string
PassFile string
SavePassphrase bool
KMSEnabled bool
KMSConfigSrcType string
KMSConfigFile string
}
type TxPoolConfig struct {
BlacklistFile string
RosettaFixFile string
AccountSlots uint64
}
type PprofConfig struct {
Enabled bool
ListenAddr string
Folder string
ProfileNames []string
ProfileIntervals []int
ProfileDebugValues []int
}
type LogConfig struct {
Folder string
FileName string
RotateSize int
RotateCount int
RotateMaxAge int
Verbosity int
VerbosePrints LogVerbosePrints
Context *LogContext `toml:",omitempty"`
}
type LogVerbosePrints struct {
Config bool
}
func FlagSliceToLogVerbosePrints(verbosePrintsFlagSlice []string) LogVerbosePrints {
verbosePrints := LogVerbosePrints{}
verbosePrintsReflect := reflect.Indirect(reflect.ValueOf(&verbosePrints))
for _, verbosePrint := range verbosePrintsFlagSlice {
verbosePrint = strings.Title(verbosePrint)
field := verbosePrintsReflect.FieldByName(verbosePrint)
if field.IsValid() && field.CanSet() {
field.SetBool(true)
}
}
return verbosePrints
}
type LogContext struct {
IP string
Port int
}
type SysConfig struct {
NtpServer string
}
type HttpConfig struct {
Enabled bool
IP string
Port int
AuthPort int
RosettaEnabled bool
RosettaPort int
}
type WsConfig struct {
Enabled bool
IP string
Port int
AuthPort int
}
type RpcOptConfig struct {
DebugEnabled bool // Enables PrivateDebugService APIs, including the EVM tracer
RateLimterEnabled bool // Enable Rate limiter for RPC
RequestsPerSecond int // for RPC rate limiter
}
type DevnetConfig struct {
NumShards int
ShardSize int
FchNodeSize int
}
// TODO: make `revert` to a separate command
type RevertConfig struct {
RevertBeacon bool
RevertTo int
RevertBefore int
}
type LegacyConfig struct {
WebHookConfig *string `toml:",omitempty"`
TPBroadcastInvalidTxn *bool `toml:",omitempty"`
}
type PrometheusConfig struct {
Enabled bool
IP string
Port int
EnablePush bool
Gateway string
}
type SyncConfig struct {
// TODO: Remove this bool after stream sync is fully up.
Enabled bool // enable the stream sync protocol
Downloader bool // start the sync downloader client
Concurrency int // concurrency used for stream sync protocol
MinPeers int // minimum streams to start a sync task.
InitStreams int // minimum streams in bootstrap to start sync loop.
DiscSoftLowCap int // when number of streams is below this value, spin discover during check
DiscHardLowCap int // when removing stream, num is below this value, spin discovery immediately
DiscHighCap int // upper limit of streams in one sync protocol
DiscBatch int // size of each discovery
}