/
collector.go
70 lines (62 loc) · 1.56 KB
/
collector.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
// Package collector contains the mempool collector service
package collector
import (
"github.com/flashbots/mempool-dumpster/common"
"go.uber.org/zap"
)
type CollectorOpts struct {
Log *zap.SugaredLogger
UID string
Nodes []string
OutDir string
CheckNodeURI string
BloxrouteAuth []string
EdenAuth []string
ChainboundAuth []string
}
// Start kicks off all the service components in the background
func Start(opts *CollectorOpts) {
processor := NewTxProcessor(TxProcessorOpts{
Log: opts.Log,
UID: opts.UID,
OutDir: opts.OutDir,
CheckNodeURI: opts.CheckNodeURI,
})
go processor.Start()
// Regular nodes
for _, node := range opts.Nodes {
conn := NewNodeConnection(opts.Log, node, processor.txC)
conn.StartInBackground()
}
// Bloxroute
for _, auth := range opts.BloxrouteAuth {
token, url := common.GetAuthTokenAndURL(auth)
startBloxrouteConnection(BlxNodeOpts{
TxC: processor.txC,
Log: opts.Log,
AuthHeader: token,
URL: url,
})
}
// Eden
for _, auth := range opts.EdenAuth {
token, url := common.GetAuthTokenAndURL(auth)
startEdenConnection(EdenNodeOpts{
TxC: processor.txC,
Log: opts.Log,
AuthHeader: token,
URL: url,
})
}
// Chainbound
for _, auth := range opts.ChainboundAuth {
token, url := common.GetAuthTokenAndURL(auth)
chainboundConn := NewChainboundNodeConnection(ChainboundNodeOpts{
TxC: processor.txC,
Log: opts.Log,
APIKey: token,
URL: url,
})
go chainboundConn.Start()
}
}