-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.go
112 lines (93 loc) · 2.58 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
106
107
108
109
110
111
112
package main
import (
"log"
"swap.io-agent/src/blockchain/ethereum/nodeApi/geth"
"swap.io-agent/src/blockchain/ethereum/transactionFormatter"
"swap.io-agent/src/blockchain/indexer"
"swap.io-agent/src/blockchain/networks"
"swap.io-agent/src/blockchain/synchronizer"
"swap.io-agent/src/blockchain/txsPipes"
"swap.io-agent/src/config"
"swap.io-agent/src/httpHandler"
"swap.io-agent/src/httpServer"
"swap.io-agent/src/levelDbStore"
"swap.io-agent/src/queueEvents"
"swap.io-agent/src/redisStore"
"swap.io-agent/src/serviceRegistry"
"swap.io-agent/src/socketServer"
"swap.io-agent/src/subscribersManager"
)
func main() {
registry := serviceRegistry.NewServiceRegistry()
err := config.InitializeConfig()
if err != nil {
log.Panicln(err)
}
networks := networks.InitializeNetworks()
err = registry.RegisterService(networks)
if err != nil {
log.Panicln(err)
}
queueEvents := queueEvents.InitializeQueueEvents()
queueEvents.ReserveQueueForUser("0")
registry.RegisterService(queueEvents)
subscribersStoreMemory, err := redisStore.InitializeDB()
if err != nil {
log.Panicf("redisStore not initialize, err: %v", err)
}
err = registry.RegisterService(&subscribersStoreMemory)
if err != nil {
log.Panicln(err)
}
subscribersStoreDisk, err := levelDbStore.InitialiseSubscribersStore()
if err != nil {
log.Panicf("Subscribers store not initialize, err: %v", err)
}
err = registry.RegisterService(subscribersStoreDisk)
if err != nil {
log.Panicln(err)
}
transactionStore, err := levelDbStore.InitialiseTransactionStore(
levelDbStore.TransactionsStoreConfig{
Name: config.BLOCKCHAIN,
DefaultScannedBlocks: config.BLOCKCHAIN_DEFAULT_SCANNED_BLOCK,
},
)
if err != nil {
log.Panicln(err)
}
err = registry.RegisterService(transactionStore)
if err != nil {
log.Panicln(err)
}
api := geth.InitializeGeth()
err = registry.RegisterService(
api,
)
if err != nil {
log.Panicln(err)
}
formatter := transactionFormatter.InitializeTransactionFormatter(transactionFormatter.TransactionFormatterConfig{
Api: api,
})
err = registry.RegisterService(
formatter,
)
if err != nil {
log.Panicln(err)
}
synchronizer.Register(registry)
subscribersManager.Register(registry)
indexer.IndexerRegister(registry)
txsPipes.NewTxsNotifierPipeRegister(registry)
txsPipes.MempoolTxsNotifierPipeRegister(registry)
socketServer.Register(registry)
httpServer.Register(registry)
httpHandlerEntity := httpHandler.InitializeServer()
err = registry.RegisterService(httpHandlerEntity)
if err != nil {
log.Panicln(err)
}
registry.StartAll()
<-make(chan struct{})
}