Skip to content

Commit b235d67

Browse files
committed
move receiversAllowAllSources logic into processor only
1 parent 90d514d commit b235d67

File tree

3 files changed

+37
-41
lines changed

3 files changed

+37
-41
lines changed

cmd/collect/main.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,22 +172,21 @@ func runCollector(cCtx *cli.Context) error {
172172

173173
// Start service components
174174
collector := collector.New(collector.CollectorOpts{
175-
Log: log,
176-
UID: uid,
177-
Location: location,
178-
OutDir: outDir,
179-
CheckNodeURI: checkNodeURI,
180-
ClickhouseDSN: clickhouseDSN,
181-
Nodes: nodeURIs,
182-
BloxrouteAuth: blxAuth,
183-
EdenAuth: edenAuth,
184-
ChainboundAuth: chainboundAuth,
185-
Receivers: receivers,
186-
ReceiversAllowedSources: receiversAllowedSources,
187-
ReceiversAllowAllSources: len(receiversAllowedSources) == 1 && receiversAllowedSources[0] == "all",
188-
APIListenAddr: apiListenAddr,
189-
MetricsListenAddr: metricsListenAddr,
190-
EnablePprof: enablePprof,
175+
Log: log,
176+
UID: uid,
177+
Location: location,
178+
OutDir: outDir,
179+
CheckNodeURI: checkNodeURI,
180+
ClickhouseDSN: clickhouseDSN,
181+
Nodes: nodeURIs,
182+
BloxrouteAuth: blxAuth,
183+
EdenAuth: edenAuth,
184+
ChainboundAuth: chainboundAuth,
185+
Receivers: receivers,
186+
ReceiversAllowedSources: receiversAllowedSources,
187+
APIListenAddr: apiListenAddr,
188+
MetricsListenAddr: metricsListenAddr,
189+
EnablePprof: enablePprof,
191190
})
192191
collector.Start()
193192

collector/collector.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ type CollectorOpts struct {
2727
EdenAuth []string
2828
ChainboundAuth []string
2929

30-
Receivers []string
31-
ReceiversAllowedSources []string
32-
ReceiversAllowAllSources bool // if true, allows all sources for receivers
30+
Receivers []string
31+
ReceiversAllowedSources []string
3332

3433
APIListenAddr string
3534
MetricsListenAddr string
@@ -57,16 +56,15 @@ func (c *Collector) Start() {
5756

5857
// Initialize the transaction processor, which is the brain of the collector
5958
c.processor = NewTxProcessor(TxProcessorOpts{
60-
Log: c.log,
61-
UID: c.opts.UID,
62-
Location: c.opts.Location,
63-
OutDir: c.opts.OutDir,
64-
CheckNodeURI: c.opts.CheckNodeURI,
65-
ClickhouseDSN: c.opts.ClickhouseDSN,
66-
HTTPReceivers: c.opts.Receivers,
67-
ReceiversAllowedSources: c.opts.ReceiversAllowedSources,
68-
ReceiversAllowAllSources: c.opts.ReceiversAllowAllSources,
69-
APIServer: apiServer,
59+
Log: c.log,
60+
UID: c.opts.UID,
61+
Location: c.opts.Location,
62+
OutDir: c.opts.OutDir,
63+
CheckNodeURI: c.opts.CheckNodeURI,
64+
ClickhouseDSN: c.opts.ClickhouseDSN,
65+
HTTPReceivers: c.opts.Receivers,
66+
ReceiversAllowedSources: c.opts.ReceiversAllowedSources,
67+
APIServer: apiServer,
7068
})
7169

7270
// Start the transaction processor, which kicks off background goroutines

collector/tx_processor.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,15 @@ var (
3434
)
3535

3636
type TxProcessorOpts struct {
37-
Log *zap.SugaredLogger
38-
OutDir string // if empty no files will be written
39-
UID string
40-
Location string // location of the collector, will be stored in sourcelogs
41-
CheckNodeURI string
42-
ClickhouseDSN string
43-
HTTPReceivers []string
44-
ReceiversAllowedSources []string
45-
ReceiversAllowAllSources bool // if true, allows all sources for receivers
46-
APIServer *api.Server
37+
Log *zap.SugaredLogger
38+
OutDir string // if empty no files will be written
39+
UID string
40+
Location string // location of the collector, will be stored in sourcelogs
41+
CheckNodeURI string
42+
ClickhouseDSN string
43+
HTTPReceivers []string
44+
ReceiversAllowedSources []string
45+
APIServer *api.Server
4746
}
4847

4948
type TxProcessor struct {
@@ -69,7 +68,7 @@ type TxProcessor struct {
6968

7069
receivers []TxReceiver
7170
receiversAllowedSources []string
72-
receiversAllowAllSources bool // if true, all sources are allowed to send transactions to the receivers
71+
receiversAllowAllSources bool
7372

7473
lastHealthCheckCall time.Time
7574

@@ -113,7 +112,7 @@ func NewTxProcessor(opts TxProcessorOpts) *TxProcessor {
113112

114113
receivers: receivers,
115114
receiversAllowedSources: opts.ReceiversAllowedSources,
116-
receiversAllowAllSources: opts.ReceiversAllowAllSources,
115+
receiversAllowAllSources: len(opts.ReceiversAllowedSources) == 1 && opts.ReceiversAllowedSources[0] == "all",
117116
}
118117
}
119118

0 commit comments

Comments
 (0)