-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (41 loc) · 939 Bytes
/
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
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/safciplak/trustwallet/api"
"github.com/safciplak/trustwallet/config"
"github.com/safciplak/trustwallet/parser"
"github.com/safciplak/trustwallet/storage"
)
func main() {
cfg, err := config.LoadConfig()
if err != nil {
fmt.Println("Error loading config:", err)
return
}
var store storage.Storage
switch cfg.StorageType {
case "memory":
store = storage.NewMemoryStorage()
default:
fmt.Println("Invalid storage type:", cfg.StorageType)
return
}
rpcURL := "https://ethereum-rpc.publicnode.com"
p := parser.NewParser(rpcURL, store)
go func() {
err := p.StartParsing()
if err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}
}()
apiServer := api.NewAPI(p)
go apiServer.Start(":8080")
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
<-stop
fmt.Println("Shutting down gracefully...")
}