forked from Gravity-Tech/gravity-node-data-extractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
executable file
·105 lines (87 loc) · 2.22 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
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
// Package classification Gravity Extractor RPC API.
//
// This application represents viable extractor methods.
// Declared methods are compulsory for appropriate extractor functioning.
//
//
// Terms Of Service:
//
// there are no TOS at this moment, use at your own risk we take no responsibility
//
// Schemes: http, https
// Host: extractor.gravityhub.org
// BasePath: /
// Version: 1.0
// License: MIT http://opensource.org/licenses/MIT
// Contact: venlab.dev <[email protected]> https://venlab.dev
//
// Consumes:
// - application/json
//
// Produces:
// - application/json
//
// Security:
// - api_key:
//
// SecurityDefinitions:
// api_key:
// type: apiKey
// name: KEY
// in: header
//
// Extensions:
// x-meta-value: value
// x-meta-array:
// - value1
// - value2
// x-meta-array-obj:
// - name: obj
// value: field
//
// swagger:meta
package main
import (
"errors"
"flag"
"github.com/Gravity-Tech/gravity-node-data-extractor/v2/config"
"github.com/Gravity-Tech/gravity-node-data-extractor/v2/extractors/binance"
"github.com/Gravity-Tech/gravity-node-data-extractor/v2/extractors/susy"
"github.com/Gravity-Tech/gravity-node-data-extractor/v2/extractors"
"github.com/Gravity-Tech/gravity-node-data-extractor/v2/server"
)
var port, configName string
var extractorType extractors.ExtractorType
func init() {
flag.StringVar(&port, "port", "8090", "Port to run on")
flag.StringVar((*string)(&extractorType), "type", susy.WavesEVM.Direct(), "Extractor Type")
flag.StringVar(&configName, "config", config.MainConfigFile, "Config file name")
flag.Parse()
}
func main() {
var extractor extractors.IExtractor
var err error
cfg, err := config.ParseMainConfig(configName)
if err != nil {
panic(err)
}
println(extractorType)
switch extractorType {
case binance.BinanceWavesBtc:
extractor = &binance.Extractor{}
default:
gateway := susy.MatchGateway(string(extractorType))
if gateway == nil {
panic(errors.New("invalid gateway"))
}
extractor, err = susy.New(cfg, gateway)
}
if err != nil {
panic(err)
}
server := server.New(extractor)
err = server.Start(port)
if err != nil {
panic(err)
}
}