-
Notifications
You must be signed in to change notification settings - Fork 11
/
jobs.go
40 lines (35 loc) · 843 Bytes
/
jobs.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
package config
func (c *Config) runJobs() {
c.scheduler.Every(1).Minute().SingletonMode().Do(c.updateFee)
c.scheduler.Every(1).Minute().SingletonMode().Do(c.updateIPWhiteList)
c.scheduler.Every(10).Seconds().SingletonMode().Do(c.updateParam)
c.scheduler.StartAsync()
}
func (c *Config) updateFee() {
fee, err := c.wdb.GetFee()
if err != nil {
return
}
c.speedTxFee = fee.SpeedTxFee
c.bundleServeFee = fee.BundleServeFee
}
func (c *Config) updateIPWhiteList() {
ips, err := c.wdb.GetAllAvailableIpRateWhitelist()
if err != nil {
return
}
ipWhiteList := make(map[string]struct{}, 0)
for _, ip := range ips {
if ip.Available {
ipWhiteList[ip.OriginOrIP] = struct{}{}
}
}
c.ipWhiteList = ipWhiteList
}
func (c *Config) updateParam() {
param, err := c.wdb.GetParam()
if err != nil {
return
}
c.Param = param
}