-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (54 loc) · 1.1 KB
/
main.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
package main
import (
"context"
"evm-scan/app"
"evm-scan/app/zkf"
"evm-scan/core/config"
"evm-scan/core/storage/database"
"evm-scan/core/utils/log"
"evm-scan/model/constant"
"github.com/bitxx/load-config/source/file"
"os"
"strings"
"time"
)
func init() {
configPath := "settings.yml"
if len(os.Args) >= 2 {
configPath = os.Args[1]
}
if !strings.HasSuffix(configPath, ".yml") {
panic("config file error,please check it.")
}
config.Setup(
file.NewSource(file.WithPath(configPath)),
database.Setup,
)
}
func main() {
var err error
ctx, cancel := context.WithCancel(context.Background())
defer func() {
if err != nil {
log.Errorf("执行异常,程序终止,失败原因:%s", err)
return
}
cancel()
log.Info("操作成功!")
time.Sleep(constant.TimeSleep) //3秒种后,窗口关闭
}()
runs := strings.Split(config.ApplicationConfig.Run, ",")
for _, run := range runs {
switch strings.TrimSpace(run) {
case "txScan":
go func() {
app.NewApp().ScanAllTransactions()
}()
case "zkfScan":
go func() {
zkf.NewZKF().StatGas()
}()
}
}
<-ctx.Done()
}