Skip to content

Commit 69f8e01

Browse files
authored
Merge pull request #114 from ethpandaops/feat/disable-event-stream
feat(consensus): Add EventStream config
2 parents 9ad01d5 + 0cb2bf8 commit 69f8e01

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

pkg/exporter/config.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ type Config struct {
2020

2121
// ConsensusNode represents a single ethereum consensus client.
2222
type ConsensusNode struct {
23-
Enabled bool `yaml:"enabled"`
24-
Name string `yaml:"name"`
25-
URL string `yaml:"url"`
23+
Enabled bool `yaml:"enabled"`
24+
Name string `yaml:"name"`
25+
URL string `yaml:"url"`
26+
EventStream EventStream `yaml:"eventStream"`
27+
}
28+
29+
type EventStream struct {
30+
Enabled *bool `yaml:"enabled"`
31+
Topics []string `yaml:"topics"`
2632
}
2733

2834
// ExecutionNode represents a single ethereum execution client.
@@ -47,6 +53,8 @@ type PairConfig struct {
4753

4854
// DefaultConfig represents a sane-default configuration.
4955
func DefaultConfig() *Config {
56+
f := false
57+
5058
return &Config{
5159
Execution: ExecutionNode{
5260
Enabled: true,
@@ -58,6 +66,10 @@ func DefaultConfig() *Config {
5866
Enabled: true,
5967
Name: "consensus",
6068
URL: "http://localhost:5052",
69+
EventStream: EventStream{
70+
Enabled: &f,
71+
Topics: []string{},
72+
},
6173
},
6274
DiskUsage: DiskUsage{
6375
Enabled: false,

pkg/exporter/exporter.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,22 @@ func (e *exporter) Serve(ctx context.Context, port int) error {
150150

151151
func (e *exporter) bootstrapConsensusClients(_ context.Context) error {
152152
opts := *beacon.DefaultOptions().
153-
EnableDefaultBeaconSubscription().
154153
EnablePrometheusMetrics()
155154

155+
if e.config.Consensus.EventStream.Enabled != nil && *e.config.Consensus.EventStream.Enabled {
156+
opts.BeaconSubscription.Topics = e.config.Consensus.EventStream.Topics
157+
158+
if len(opts.BeaconSubscription.Topics) == 0 {
159+
opts.EnableDefaultBeaconSubscription()
160+
}
161+
162+
e.log.WithField(
163+
"topics", strings.Join(opts.BeaconSubscription.Topics, ", "),
164+
).Info("Enabling beacon event stream with topics...")
165+
166+
opts.BeaconSubscription.Enabled = true
167+
}
168+
156169
e.beacon = beacon.NewNode(e.log, &beacon.Config{
157170
Addr: e.config.Consensus.URL,
158171
Name: e.config.Consensus.Name,

0 commit comments

Comments
 (0)